Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VBA to identify/set motionpathe start and end points

881 views
Skip to first unread message

D Riggins

unread,
May 18, 2009, 3:06:25 PM5/18/09
to
Can anyone supply sample VBA to identify the coordinates of the start/end
points of a motion path? Same question for VBA to set the coordinates of
the start/end points of a motion path?

The VBA help for powerpoint 2007 is not very helpful on this subject.

Austin

unread,
May 18, 2009, 3:54:03 PM5/18/09
to
This should help:

Sub AddMotionPath()

Dim shpNew As Shape
Dim effNew As Effect
Dim aniMotion As AnimationBehavior

Set shpNew = ActivePresentation.Slides(1).Shapes _
.AddShape(Type:=msoShape5pointStar, Left:=0, _
Top:=0, Width:=100, Height:=100)
Set effNew = ActivePresentation.Slides(1).TimeLine.MainSequence _
.AddEffect(Shape:=shpNew, effectId:=msoAnimEffectCustom, _
Trigger:=msoAnimTriggerWithPrevious)
Set aniMotion = effNew.Behaviors.Add(msoAnimTypeMotion)

With aniMotion.MotionEffect
.FromX = 0
.FromY = 0
.ToX = 500
.ToY = 500
End With

End Sub

--
Austin Myers
AT&W Technologies

Creators PowerPoint Add-Ins
www.playsforcertain.com


"D Riggins" <DRig...@discussions.microsoft.com> wrote in message
news:9B9C3621-49EE-48D1...@microsoft.com...

D Riggins

unread,
May 19, 2009, 7:21:09 AM5/19/09
to
Sorry, that's right out of the MS Help. It shows how to add a new shape and
then add a motion effect. I need to figure out how to identify the existing
motion effects on a slide and their beggining and ending points. Then I need
to know how to manipulate those beggining and ending points. Once I can
figure out what object, collection, method or property to manipulate, the
rest shoudl be easy. In prior versions of MS VBA help the object model used
to be represented as a tree structure so you could trace this quite easily.
In 2007 help this featue is missing (or impossible to find) so it is diffult
to figure this out.

Chirag

unread,
May 19, 2009, 8:37:57 AM5/19/09
to
Effects 86 to 149 are path effects. You can iterate over the effects
assigned for shapes on a slide and check its effect type as follows:

Sub IterateOverEffects()
Dim Eff As Effect
Dim I As Long

With ActivePresentation.Slides(1).TimeLine
For Each Eff In .MainSequence
If (Eff.EffectType >= msoAnimEffectPathCircle) And _
(Eff.EffectType <= msoAnimEffectPathRight) Then

' We have identified a motion path

For I = 1 To Eff.Behaviors.Count
If Eff.Behaviors(I).Type = msoAnimTypeMotion Then
' Use Eff.Behaviors(I).MotionEffect property
End If
Next
End If
Next
End With
End Sub

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html

"D Riggins" <DRig...@discussions.microsoft.com> wrote in message
news:9B9C3621-49EE-48D1...@microsoft.com...

D Riggins

unread,
May 19, 2009, 9:32:03 AM5/19/09
to
Thanks,

Guess I should be careful what I wish for. Looks like the Motion paths are
defined not with begin/end points but as movements expressed in fractions of
the slide size.

Shyam Pillai

unread,
May 19, 2009, 11:17:20 AM5/19/09
to
Hi,
You should look at the Path property for motion path which represents a VML
string. You can generate the co-ordinates from the VML information. The VML
string is a collection of coordinates for a Line or Bezier curve (for
powerpoint purposes). The values are fractions of the slide dimensions. The
other properties like FromX,FromY etc are not reliable.

VML path for circle animation is:
M 0 0 C 0.069 0 0.125 0.07467 0.125 0.16667 C 0.125 0.25867 0.069
0.33333 0 0.33333 C -0.069 0.33333 -0.125 0.25867 -0.125 0.16667
C -0.125 0.07467 -0.069 0 0 0 Z

M indicates Move To a point, the begining of the path.
Z indicates that it is a closed path. If final co-ordinate is not the same
as the first, then you should close the path.
C Bezier curver
L Line

The above string has 4 bezier curves co-ordinates required to draw the
circle.
(0, 0) C (0.069, 0) (0.125, 0.07467) (0.125, 0.16667)
(0.125, 0.16667) C (0.125, 0.25867) (0.069, 0.33333) (0, 0.33333)
(0.069, 0.33333) (0, 0.33333) C (-0.069, 0.33333) (-0.125, 0.25867)
(-0.125, 0.16667)
(-0.125, 0.16667) C (-0.125,0.07467) (-0.069, 0) (0, 0)

Capital alphabhets represent absolute values with respect to shapes. 0,0
represents the centre of the shape.
For X co-ordinate multiply the value with 720 and for Y co-ordinate multiple
with 540 to get the value in points. If the VML values are absolute then you
will now need to account for the shapes position on the slide and perform
the calculations to arrive at the actual positions on the screen.

Regards,
Shyam Pillai

Image Importer Wizard: http://skp.mvps.org/iiw.htm

"D Riggins" <DRig...@discussions.microsoft.com> wrote in message
news:9B9C3621-49EE-48D1...@microsoft.com...

Steve Rindsberg

unread,
May 19, 2009, 2:33:23 PM5/19/09
to

> Capital alphabhets represent absolute values with respect to shapes. 0,0
> represents the centre of the shape.
> For X co-ordinate multiply the value with 720 and for Y co-ordinate multiple
> with 540 to get the value in points.

Shyam, would it always be 720/540 or would it vary depending on
ActivePresentation.PageSetup.SlideHeight / .SlideWidth?

I'm guessing the latter.

Shyam Pillai

unread,
May 19, 2009, 6:18:39 PM5/19/09
to
Sorry for not being clear. This value is dependant on the slide dimensions.
I just took the defaults.

Regards,
Shyam Pillai

Handout Wizard: http://skp.mvps.org/how

"Steve Rindsberg" <ab...@localhost.com> wrote in message
news:VA.00004dd...@localhost.com...

Steve Rindsberg

unread,
May 19, 2009, 9:00:28 PM5/19/09
to
In article <4342D321-4A5E-4D54...@microsoft.com>, Shyam Pillai
wrote:

> Sorry for not being clear. This value is dependant on the slide dimensions.
> I just took the defaults.

Thanks ... I figured that it pretty much had to be thataway.

>
> Regards,
> Shyam Pillai
>
> Handout Wizard: http://skp.mvps.org/how
>
> "Steve Rindsberg" <ab...@localhost.com> wrote in message
> news:VA.00004dd...@localhost.com...
> >
> >> Capital alphabhets represent absolute values with respect to shapes. 0,0
> >> represents the centre of the shape.
> >> For X co-ordinate multiply the value with 720 and for Y co-ordinate
> >> multiple
> >> with 540 to get the value in points.
> >
> > Shyam, would it always be 720/540 or would it vary depending on
> > ActivePresentation.PageSetup.SlideHeight / .SlideWidth?
> >
> > I'm guessing the latter.
> >
> >
> >


==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/

PPTools add-ins for PowerPoint
http://www.pptools.com/

Message has been deleted
Message has been deleted
0 new messages