|  | How can I find out the start point and the end point of msoL |  | |
| | | lai |  |
| Posted: Wed Sep 03, 2008 11:19 pm Post subject: How can I find out the start point and the end point of msoL |  |
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 |
| |
| | | Steve Rindsberg |  |
| Posted: Thu Sep 04, 2008 2:07 am Post subject: Re: How can I find out the start point and the end point of |  |
| Quote: | 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.
|
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: LINK PPTools: LINK ================================================ Live and in personable in the Help Center at PowerPoint Live Sept 21-24, San Diego CA, USA LINK |
| |
| | | lai |  |
| Posted: Thu Sep 04, 2008 3:33 pm Post subject: Re: How can I find out the start point and the end point of |  |
On Sep 3, 8:07 pm, Steve Rindsberg <ab...@localhost.com> wrote:
| Quote: | 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.
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 |
| |
| | | Steve Rindsberg |  |
| Posted: Thu Sep 04, 2008 8:06 pm Post subject: Re: How can I find out the start point and the end point of |  |
| |  | |
| Quote: | 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?
|
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: LINK PPTools: LINK ================================================ Live and in personable in the Help Center at PowerPoint Live Sept 21-24, San Diego CA, USA LINK |
| |
| | | lai |  |
| Posted: Fri Sep 05, 2008 3:18 pm Post subject: Re: How can I find out the start point and the end point of |  |
| |  | |
| Quote: | 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: LINK PPTools: LINK ================================================ 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... |
| |
| | | lai |  |
| Posted: Fri Sep 05, 2008 3:51 pm Post subject: Re: How can I find out the start point and the end point of |  |
| |  | |
On Sep 5, 9:18 am, lai <yujing....@gmail.com> wrote:
| Quote: | 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...
|
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 |
| |
| | | Steve Rindsberg |  |
| Posted: Fri Sep 05, 2008 5:30 pm Post subject: Re: How can I find out the start point and the end point of |  |
| Quote: | 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
|
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: LINK PPTools: LINK ================================================ Live and in personable in the Help Center at PowerPoint Live Sept 21-24, San Diego CA, USA LINK |
| |
| | | lai |  |
| Posted: Fri Sep 05, 2008 5:40 pm Post subject: Re: How can I find out the start point and the end point of |  |
Thanks
On Sep 5, 11:30 am, Steve Rindsberg <ab...@localhost.com> wrote:
| Quote: | 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
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 |
|
| |
|
|