View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions,microsoft.public.excel
Greg Wilson Greg Wilson is offline
external usenet poster
 
Posts: 747
Default Measure length of an AutoShape Line?

Try:

Sub ShowLineLength()
If TypeName(Selection) = "Line" Then
Range("A1").Value = GetLen(Selection)
End If
End Sub

Function GetLen(shp As Line) As Single
Dim W As Single, H As Single
W = shp.Width: H = shp.Height
GetLen = Sqr(W ^ 2 + H ^ 2)
End Function

"Line" is now considered a "hidden member" and possibly is no longer
supported in some versions beyond xl2000 which I am using. This can be fixed
if this is the case with you. Will be a little less concise however.

Regards,
Greg


"John" wrote:

Is there a function or way in Excel to measure the length of an autoshape
line?

What I would like to do is be able to draw an autoshape line and then in an
Excel cell display the length of that line.

Thank you in advance to any help provided!

Best Regards,
John




---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0615-3, 04/14/2006
Tested on: 4/16/2006 4:12:11 PM
avast! - copyright (c) 1988-2005 ALWIL Software.
http://www.avast.com