VBA: AnimationSettings.Animate = msoTrue resets animation timings

K

Kevin Dufendach

I'm using the following code do set the selected objects as "animate
with previous" (equivalent to going [slide show] --> [custom
animation] --> [add effect] --> [entrance] --> [appear] --> [with
previous]). However, whenever I run the
oShape.AnimationSettings.Animate = msoTrue line, any previously
animated objects' timings get reset to 0.5, so there's a delay. Am I
doing something wrong? Is there a better way to animate objects?

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub SetSelectedToAnimateAfterPrev()

Dim oShape As Shape
Dim oAnimObject As Object

On Error GoTo OnError

'Set Selected = ActiveWindow.Selection ' uncomment this line for
debugging purposes

For Each oShape In ActiveWindow.Selection.ShapeRange
oShape.AnimationSettings.Animate = msoTrue
'After previous line, the previously animated shapes' timings
get reset to 0.5

oShape.AnimationSettings.AdvanceMode = ppAdvanceOnTime
oShape.AnimationSettings.AdvanceTime = 0

For Each oAnimObject In
ActiveWindow.Selection.SlideRange.TimeLine.MainSequence
If oAnimObject.Shape.Name = oShape.Name Then
oAnimObject.Timing.TriggerType =
msoAnimTriggerWithPrevious
oAnimObject.Timing.Duration = 0.001
End If
Next oAnimObject
Next oShape

OnError:

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
K

Kevin Dufendach

Thanks for the tip, John. That makes a lot more sense now why I was
getting such strange results. Looking quickly at the "TimeLine
Property" in the help docs helped me solve my problem. My corrected
code (which is also quite a bit simpler) is below if anyone is
interested:

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub SetSelectedToAppearAfterPrev()
Dim oShape As Shape

On Error GoTo OnError

For Each oShape In ActiveWindow.Selection.ShapeRange

ActiveWindow.Selection.SlideRange.TimeLine.MainSequence.AddEffect _
Shape:=oShape, EffectID:=msoAnimEffectAppear,
trigger:=msoAnimTriggerWithPrevious
Next oShape

OnError:

End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 

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