VBA to identify/set motionpathe start and end points


D Riggins

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.


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, _
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

D Riggins

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.


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
End If
End With
End Sub

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously

D Riggins


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

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
(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.

Shyam Pillai

Image Importer Wizard: http://skp.mvps.org/iiw.htm
Dec 8, 2022
Reaction score
You can change the path of the effect with VBA though i used that but then again i was using simple line animation

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