Saturday, May 14, 2016

PowerPoint VBA disappear animation effect

Tags:

PowerPoint VBA disappear animation effect

Power Point VBA disappear animation effect

PowerPoint msoAnimEffectDisappear

Power Point msoAnimEffectDisappear


Without any complications, PowerPoint has four group of effects:

[1] Entrance effects

[2] Emphasis effects

[3] Exit effects

[4] Motion paths

PowerPoint has a list of animation effects names that you can find in the following Microsoft page (by the way, some of them does not appear in the GUI of PowerPoint, so you can call them by VBA):
https://msdn.microsoft.com/en-us/library/office/ff744314.aspx

The tricky part is that there is no exit animation effects in VBA because exit animation effect is just the reverse (opposite) of the entrance effect (see the pictures below and compare). In other words, there are set of animation effects that can be configured to be "Entrance" or "Exit" where the default configuration is "Entrance".


That means -in our case- there is no "Disappear" effect to be called by effect name like "msoAnimEffectDisappear", but it can be called by configuring the effect "msoAnimEffectAppear" to be "Exit".




The following macro adds "Disappear" effect to shape number (1) in slide number (1)

Private Sub AddDisAppearEffect()

Dim Shape1 As Shape

Dim ShapeEffect as Effect

Set MySlide = ActivePresentation.Slides(1)

Set Sahpe1= MySlide.Shapes(1)

' Add the appear effect
Set ShapeEffect = MySlide.TimeLine.MainSequence.AddEffect _
(Shape1, msoAnimEffectAppear, , msoAnimTriggerAfterPrevious)

ShapeEffect.Exit = msoCTrue      ' This line to configure the animation to be exit effect

End Sub

Now, I think it is done. Stop googling this again :)