need to get the vertices/endpoints of a line
Hi NickHK,
Thanks very much for the post. Unfortunately, this code did work in 2002,
but the Nodes property is no longer valid for a line in 2007. The
Nodes.Count is 0, and if I try to get the .Nodes.Points, it gives the error
"The index into the specfied collection is out of bounds." The Insert and
Item methods of the lines Nodes also don't work. I get a similar error when
trying to access the vertices. And I haven't found a way to convert the
line/connector to a freeform shape so those methods are valid.
Broderick
"NickHK" wrote:
This works in XL2002. Can't say about XL2007:
Private Sub CommandButton1_Click()
Dim ShpIt As Shape
Dim i As Long
Dim NodePoint As Variant
Set ShpIt = Worksheets(2).Shapes("Line 3")
With ShpIt
For i = 1 To .Nodes.Count
NodePoint = .Nodes(i).Points
Debug.Print NodePoint(1, 1), NodePoint(1, 2)
Next
End With
End Sub
NickHK
"broderick" wrote in message
...
I am using Excel 2007, and need to get the vertices (endpoints) of a line.
Neither the Vertices nor Nodes methods of the Shape object work for a line
(as stated in their Help). In an earlier version, I used a workaround of
inserting a dummy second node in the line, and Excel automatically
converted
the line to a freeform polygon, and then the Vertices method worked. That
workaround no longer works. I also tried setting the Type property of the
line to msoFreeform, and get an error. The only information I seem to be
able to get is the Left, Right, Width and Height (bounding rectangle), so
I
don't know whether the line has a negative or positive slope (goes from
top
left to bottom right, or the reverse). Any suggestions are greatly
appreciated.
|