Animating Shapes in PowerPoint 2000 and 97 (Part 2 of 4)
So yesterday we started talking about how to animate shapes if you’re programming for PowerPoint 97 or 2000. Today we continue by discussing how to trigger your animation effects, and control the order in which they occur. We’ll also touch on how to further customize a shape’s animation, by adding sound and/or changing the shape’s post-animation appearance.
Setting the Order in Which PowerPoint Animates Shapes
The AnimationOrder property of each shape determines the order in which PowerPoint animates the shape, from the lowest number to the highest. By default, if you don’t explicitly specify an animation order, PowerPoint sets the animation order in the order in which you set the Shape objects to be animated; that is, the order in which you set the Animate property to msoTrue for each Shape object. The first shape for which you set Animate to msoTrue is first in the animation sequence, the next second, and so on. If you later set a Shape objects AnimationOrder property to a specific value, PowerPoint re-orders the index of each shape’s animation accordingly.
The following code demonstrates this. The code creates a new blank slide, then adds four shapes and specifies that each be animated. No animation index is specified, so PowerPoint sets each shape as the next in the animation sequence as the code specifies each to be animated. The code prints the name and animation order of each shape. Then the code adds a fifth shape, and explicitly sets the animation index of this shape to ‘2’. PowerPoint automatically resets the animation order index of each shape that comes after the new shape in the animation order. Lastly, the code prints the name of each shape, and its revised animation order.
Sub DemoAnimationIndexing()
Dim iCount As Integer
Dim objShape As Shape
ActivePresentation.Slides.Add Index:=1, Layout:=ppLayoutBlank
With ActivePresentation.Slides(1).Shapes
For iCount = 1 To 4
Set objShape = .AddShape(msoShapeCube, 100, 100, 100, 100)
objShape.Name = "Cube " & iCount
With objShape.AnimationSettings
.Animate = msoTrue
'.AnimationOrder = iCount
End With
Debug.Print objShape.Name & _
" Animation Order: " & _
objShape.AnimationSettings.AnimationOrder
Next iCount
Set objShape = .AddShape(msoShapeCube, 100, 100, 100, 100)
objShape.Name = "Cube 5"
With objShape.AnimationSettings
.Animate = msoTrue
.AnimationOrder = 2
End With
For iCount = 1 To .Count
Debug.Print .Item(iCount).Name & _
" Animation Order: " & _
.Item(iCount).AnimationSettings.AnimationOrder
Next iCount
End With
End Sub
Setting How PowerPoint Advances to the Next Animation Effect
You can specify when you want PowerPoint to advance to the next shape animation in the animation sequence: either when the user clicks the slide, or after a specified time interval. Use the AdvanceMode property to specify whether you want PowerPoint to perform a shape’s animation when the user clicks on the slide, or after a certain period of time. For timed advancement, use the AdvanceTime property to specify the time, in seconds, PowerPoint should wait after the last animation effect before performing the specified animation.
By default, the AdvanceMode property is set to ppAdvanceModeOnClick.
The following example sets a shape to be the first shape animated when the slide loads, and for PowerPoint to automatically animate the shape five seconds after the slide loads.
Dim objShape As Shape
With ActivePresentation.Slides(1).Shapes
Set objShape = .Item("Title")
With objShape.AnimationSettings
.EntryEffect = ppEffectBlindsHorizontal
.AnimationOrder = 1
.AdvanceMode = ppAdvanceOnTime
.AdvanceTime = 5
End With
End With
Further Customizing Your Animation Effects
Once you’ve set which shapes get animated, with which animation effects and in which order, you can customize the animation effect for each shape even further. You can add a sound effect to a shape’s animation, and alter the appearance of a shape once PowerPoint has performed the shape’s animation effect.
In addition, certain types of Shape objects have additional animation functionality. You can animate text and charts to build piece-by-piece, to reveal the complete shape. If you animate media or OLE objects, you can customize how they perform as part of their animation effect.
Adding Sound to Your Animation Effects
You can also add a sound effect to a shape’s animation effect. This is different from adding sound files to the slide itself. An animation sound effect is not an independent shape that appears on the slide; rather, it is a sound file that plays when PowerPoint animates the shape to which it is assigned. The SoundEffect object, a child of the AnimationsSettings object, contains members that enable you to set and control a Shape object’s animation sound effect.
Use the ImportFromFile method to specify a sound file you want imported and used as an animation sound effect. You can also use a sound effect that is native to PowerPoint by setting the Name property.
You can also use the SoundEffect object to stop a sound effect from a previous shape’s animation effect. By default, PowerPoint plays each sound effect through once, unless the next shape’s animation starts first, and it has a sound effect. But you might want to stop the previous sound effect when the next shape’s animation begins, but that shape’s animation effect does not have a sound effect. In this case, set the SoundEffect.Type property of the second shape to ppSoundEffectStopPrevious. This stops the previous sound effect; you do not need to specify a sound file for the sound effect.
For shapes with build animations, such as text or charts, the sound effect restarts each time PowerPoint animates the next sub-object. For example, if you set the TextLevelEffect property to ppAnimateByFirstLevel, the sound effect restarts each time PowerPoint animates the next first level paragraph. In addition, if you set the TextUnitEffect property to ppAnimateByCharacter or ppAnimateByWord, then the sound effect restarts each time PowerPoint animates the next character or word, respectively.
The following example specifies the animation settings for the selected shape on a slide. The code specifies that PowerPoint display the text in the shape character by character, playing the typewriter sound effect each time PowerPoint displays a new character. Note that “Typewriter” is a native PowerPoint sound effect.
With .Shapes("Body Text").AnimationSettings
.TextLevelEffect = ppAnimateByFirstLevel
.TextUnitEffect = ppAnimateByCharacter
.SoundEffect.Name = "Typewriter"
End With
Changing the Appearance of the Shape Once PowerPoint Completes the Animation Effect
You can also specify how you want the Shape to appear once the animation is finished by using the AfterEffect property. You can use after effects to de-emphasize a slide element once you want to move the user’s focus elsewhere, and to conserve slide ‘real estate’. For example, you can set shapes or text to turn a neutral color, so they fade into the slide background and do not distract from the slide shape being animated next. You can also set PowerPoint to render a shape invisible, either immediately after PowerPoint finishes animating it, or on the next slide click. With the exception of ppAfterEffectHideOnClick, PowerPoint performs the specified after effect as soon as it finishes animating the shape.
By default, the AfterEffect property is set to ppAfterEffectNothing.
If you specify ppAfterEffectDim, you can use the DimColor property to specify a ColorFormat object representing the dim color you want. The dim color is the color PowerPoint turns the shape or text once PowerPoint is done animating it.
Next time, we’ll cover build effect animations: what they are, and how to assign and customize them.
Comments
- Anonymous
July 30, 2008
PingBack from http://alexisnewsblog.gratishotell.com/animatedshapes.html