如何利用vba判断powerpoint中自定义动画播放的速度
如何利用VBA判断已经完成的powerpoint作品中某张幻灯片中的某个对象的自定义动画效果及播放速度是否正确。
如:设置第5张幻灯片的正文动画为“展开”效果,速度为“中速”,怎样利用VBA判断其操作是否正确。
[解决办法]
If ActivePresentation.Slides(5).SlideShowTransition.EntryEffect = ppEffectBoxOut And _
ActivePresentation.Slides(5).SlideShowTransition.Speed = ppTransitionSpeedMedium Then
MsgBox "right"
Else
MsgBox "wrong"
End If
If ActivePresentation.Slides(2).TimeLine.MainSequence.Item(1).Shape.Name = "Rectangle 2" Then
If ActivePresentation.Slides(2).TimeLine.MainSequence.Item(1).Timing.Duration = 2 And _
ActivePresentation.Slides(2).TimeLine.MainSequence.Item(1).EffectParameters.Direction = msoAnimDirectionOut Then
MsgBox "right"
Else
MsgBox "wrong"
End If
End If
Sub AddAnimation()
Dim sldActive As Slide
Dim shpSelected As Shape
Dim slEffect As Effect
Set sldActive = ActivePresentation.Slides(5)
Set shpSelected = sldActive.Shapes(1)
Set slEffect = sldActive.TimeLine.MainSequence.AddEffect(Shape:=shpSelected, effectId:=msoAnimEffectBox)
slEffect.EffectParameters.Direction = msoAnimDirectionOut
slEffect.Timing.Duration = 2
End Sub
Sub CheckAnimation()
If ActivePresentation.Slides(5).TimeLine.MainSequence.Count > 0 Then
If ActivePresentation.Slides(5).TimeLine.MainSequence.Item(1).Timing.Duration = 2 And _
ActivePresentation.Slides(5).TimeLine.MainSequence.Item(1).EffectParameters.Direction = msoAnimDirectionOut Then
MsgBox "right"
Else
MsgBox "wrong"
End If
Else
MsgBox "no animation"
End If
End Sub