How can I find out the start point and the end point of msoLine inpowerpoint?

L

lai

Hi
I am trying to write automation code for powerpoint. When I try to
parse a straight line in powerpoint
I dont know from which object I can get the start point and end point
of the line.

I tried shapeNodes, but there is no shapenode under the line shape

Thank you
Yujing
 
L

lai

The shape's .Top and .Left will give you one end point.

Top + .Height  and .Left + .Width will give you the other end point.

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
Live and in personable in the Help Center at PowerPoint Live
Sept 21-24, San Diego CA, USAwww.pptlive.com

Thanks for your fast reply.

There is still a little problem by using the left-top of the shape as
start point.
For example, if the line goes 2 o'clock direction, the left - bottom
will be the
start point.

Any idea about this?

Thanks
Yujing
 
L

lai

Ah. Good question. Thanks!

This should help. It works with the current selection, just as a test:

Sub test()
Dim oSh As Shape
Dim x As Long

Set oSh = ActiveWindow.Selection.ShapeRange(1)

With oSh
' Here's the information we already know how to get
Debug.Print "Left: " & .Left
Debug.Print "Top: " & .Top
Debug.Print "Left+Width: " & .Left + .Width
Debug.Print "Top+Height: " & .Top + .Height
Debug.Print .Nodes.Count

' now the same information but in "node order"
' the first pair of coordinates will be the beginning
' point on the line, the second pair will be the end point
For x = 1 To .Nodes.Count
Debug.Print .Nodes(x).Points(1, 1)
Debug.Print .Nodes(x).Points(1, 2)
Next
End With
End Sub

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
Live and in personable in the Help Center at PowerPoint Live
Sept 21-24, San Diego CA, USAwww.pptlive.com

Hi

As I am using C automation code, there is something wrong....
when I tried to get the Notes (similar to what u are doing)

CShapeNotes shapeNotes = shape.get_Notes();
long count = shapeNotes.get_Count();
Here, the count is 0!! :(

Tried to do the same to a curve or free drawing line.
the count of notes is not equal to 0...
 
L

lai

Hi

As I am using C automation code, there is something wrong....
when I tried to get the Notes (similar to what u are doing)

CShapeNotes shapeNotes = shape.get_Notes();
long count = shapeNotes.get_Count();
Here, the count is 0!! :(

Tried to do the same to a curve or free drawing line.
the count of notes is not equal to 0...

Just now I tried to run ur code in the ppt 2007.
The count is also equal to 0.
So we still could not get the Node order, as there is no node....

Below is the result...
Left: 78.74803
Top: 151.8742
Left+Width: 585.0016
Top+Height: 320.6254
0 <----------------Node count
 
L

lai

Thanks

I'm seeing the same thing here in 2007, while it works fine in 2003.

I'm not sure what to suggest next, really.  I'll report it as a bug, though.

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
Live and in personable in the Help Center at PowerPoint Live
Sept 21-24, San Diego CA, USAwww.pptlive.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top