Export (0) Print
Expand All

Creating Animation Sequences in PowerPoint 2002 and PowerPoint 2003 (Part 1)

Office 2003

Andrew May
Microsoft Corporation

June 2004

Applies to:
    Microsoft Office PowerPoint 2003
    Microsoft PowerPoint 2002

Summary: Learn how to use a completely redesigned and greatly expanded section of the PowerPoint object model for creating, customizing, and controlling the animation effects on a slide. Discover how the new TimeLine object model provides more flexibility and options for richer animations then ever before. (12 printed pages)


Compatibility Issues
How Animation Sequences are Structured
Adding an Animation Sequence
Adding Effects to an Animation Sequence


In Microsoft Office PowerPoint 2003 and Microsoft PowerPoint 2002, the term animation refers to special visual or sound effects you add to shapes on a slide. Animation effects give motion to text, pictures, and other content on your slides. Besides adding action, they help you guide audience focus, emphasize important points, transition between slides, and maximize slide space by making shapes on the slide visible or invisible at specific times.

PowerPoint 2002 added a completely redesigned and greatly expanded object model for creating, customizing, and controlling the animation effects on a slide. This new object model, contained in the TimeLine object, provides more flexibility and options for richer interactive animations then ever before.

Note   This article is the first of two articles about Creating Animation Sequences in PowerPoint 2002 and PowerPoint 2003. For more information, see Creating Animation Sequences in PowerPoint 2002 and PowerPoint 2003 (Part 2).

Compatibility Issues

To provide backward compatibility, PowerPoint retained the previous object model structure dealing with animation effects, contained in the AnimationSettings object. Unfortunately, because of basic differences in the organization, the two object models are not compatible. Using the AnimationSettings object model for programming PowerPoint 2002 and later versions is not recommended, as it can have unexpected and undesirable results for your animation sequences. Unlike the PowerPoint 2002 and PowerPoint 2003 object models, the only animation effects the Microsoft PowerPoint 2000 and earlier object models support are entrance effects. When you use the AnimationSettings object to set effect properties, PowerPoint assumes you are programming for the PowerPoint 2000 or earlier object models, and therefore takes the following actions:

  • Deletes any animation effects that are not entrance effects, for the entire slide. This includes effects that you added using the user interface.
  • Converts any entrance effects that are only available in PowerPoint version 2002 or later to effects of type ppEffectAppear.
  • Removes all custom timing for entrance effects, as PowerPoint 2000 and earlier versions do not allow for custom timing of animations.
  • Deletes interactive sequences for the slide, as interactive sequences are not supported in PowerPoint 2000 and earlier versions.

If you're familiar with using the AnimationSettings object model, and want to learn how the new TimeLine object model differs from and offers distinct advantages over it, see Comparing Ways to Control Animation in PowerPoint 2002 and PowerPoint 2003.

To give you an understanding of how the TimeLine object model is organized, this article discusses the conceptual structure of the slide timeline. We then demonstrate how to put this understanding to use in writing code that adds, customized, and controls animation sequences.

How Animation Sequences are Structured

The slide timeline contains the animation sequences you create for that slide. An animation sequence is just an ordered series of animation effects applied to shapes on the slide. A simple sequence might go something like this:

  • A soundtrack starts playing.
  • The title of the slide materializes.
  • Two bullet points fly in from the right, one after the other.
  • A picture moves in from the left edge of the slide.
  • The bullet points fly out to the right, together.

Each slide (and master slide) includes a single TimeLine object that acts as a container for the animation sequences you create for that slide.

There are two kinds of animation sequences:

  • The main sequence, which begins starts by default when the slide loads.
  • Interactive sequences, which are initiated (or triggered) by the user clicking a specific shape.

You can create any number of interactive sequences that can be triggered by user interaction at any time while the slide display. For each interactive sequence, you designate one shape as the trigger shape; when the user clicks that shape during the presentation, the interactive sequence starts. These sequences may run concurrently with the main sequence, or after, or not at all, based on whether the user clicks the shape that triggers that particular sequence.

There is only one main sequence for each slide. You are not required to specify a main sequence in a slide to add interactive sequences. By default, each slide automatically contains a main sequence. However, that sequence contains no animation effects to perform until you add effects to it.

For example, when the slide loads, the main sequence starts. At the same time, a user could click one or more shapes, and thereby start multiple interactive sequences. In this case, these sequences run at the same time as the main sequence. Sequences are self-contained, and do not interact with each other.

Each sequence in turn is a collection of ordered animation effects, each of which isen assigned to animate a specific shape. Each effect is a discrete animation performed on a shape, or, in the case of text boxes, charts, or diagrams, part of a shape.

You can assign any number of effects to a single shape. Different sequences can involve the same shapes, and a specified sequence can affect the same shape multiple times while it runs. You can specify one effect for when the shape enters the slide, one or more if you want the shape to be animated as the sequence progresses, and a totally different effect if you want the shape to exit the slide.

The following figure illustrates the timeline of an example slide, which contains one main sequence and two interactive sequences.

Figure 1. Conceptual Structure of the TimeLine object model

This example shows some of the flexibility and complexity available for animating slides. In this example, the slide has a main sequence that starts as soon as the slide loads. Notice that the main sequence contains two effects for both Shape B and E. The effects assigned to Shape B run one after the other, while the first effect assigned to Shape E runs, then an effect for Shape F runs, and then the second effect for Shape E is performed. Also, Shapes B, D, E, and F are each animated as part of the main sequence and one of the interactive sequences. Lastly, the interactive sequences animate slide shapes in a different order than the main sequence.

How Animation Effects Work

Effects can be of several different types. Each type performs a different animation function upon the assigned shape.

  • Entrance. Entrance effects are animations that control how the shape becomes visible on the slide. For example, this could involve having the shape appear to move onto the slide from outside the slide boundaries, such as flying in from the right edge of the slide; or having the shape become visible in place in a particular manner, such as dissolving into visibility.

    If the first effect assigned to a shape in the main sequence is an entrance effect, that shape is not initially visible when the slide is loaded. The shape becomes visible when PowerPoint performs the entrance effect assigned to it. You do not have to assign an entrance effect to a shape in order to assign other effects to it.

  • Emphasis. Emphasis effects refer to effects that do not move the shape on the slide. You can use emphasis effects to call attention to shapes already displayed on the slide. Using emphasis effects, you can make shapes rotate, grow or shrink, change color, and other effects.
  • Motion path. A motion path is an invisible track you lay on your slide for a shape to run along. For example, you can move text from one place on your slide to another; create a hand-drawn entrance or exit for a piece of art; or lay a path that an arrow could follow at crucial points in your narrative, to show a process. Unlike with an entrance or exit effect, you can use a path simply to move something on the slide from one position to another.
  • Object Action. Object action effects include actions that the shape itself performs, such as a media file playing.
  • Exit. Exit effects are animations that control how the shape becomes invisible on the slide. You can use exit effects to appear to remove shapes from the slide, to make room for other shapes on the slide, or to focus attention on the remaining shapes on the slide.

You can assign the different types of effects to a shape in any order. Note, however, that in some instances, the type of effect and the order in which you arrange the effects determines whether they have logical or discernable effects during your presentation. PowerPoint performs the specified effects, whether or not the shape the effect is assigned to is currently visible on the slide. Consider the following example:

You specify two effects for a shape; first, an exit effect, then an emphasis effect. When PowerPoint performs the exit effect, the shape is rendered invisible. PowerPoint then performs the emphasis effect, but this effect has no discernable effect because the shape is already invisible. However, suppose you insert an entrance effect into the sequence between the two effects, and assign it to the shape in question. The shape is rendered invisible when PowerPoint performs the first exit effect, then reappears on the slide when the entrance effect is performed. In this case, the emphasis effect is visible because the shape is visible when the effect is performed.

Note that effect order can also matter across animation sequences. In the example above, suppose you put the exit effect in one animation sequence, and inserted the emphasis effect in a different animation sequence. If PowerPoint performs the exit effect in the first animation sequence first, then the shape is invisible when PowerPoint performs the emphasis effect in the other animation sequence.

The general process for creating an animation sequence is:

  • Add your shapes to the slide.
  • Add the sequence. By default, each slide has a main sequence.
  • Add effects to the sequence, including assigning them to the shapes you want them to affect, specifying what triggers each effect, and setting the order in which to perform the effects.

Adding shapes to a slide is a straightforward process, and outside the scope of this article, so let's focus on the last two steps in the process.

Adding an Animation Sequence

Each slide automatically has a main sequence, which you can access through the MainSequence property of the slide's TimeLine object.

For interactive sequences, use the Sequences.Add method to add a new interactive sequence to a slide. Access the TimeLine object's collection of interactive sequences using the InteractiveSequences property. Note that, because interactive sequences are triggered by the user, and you can trigger them in any order, the index of the interactive sequence has no relationship to the order in which the interactive sequences might actually be preformed.

Adding Effects to an Animation Sequence

You'll have at least one Effect object for each shape on your slide that is animated. If you have five shapes on your slide that are animated, you'll have at least five Effect objects, even if each shape is animated in exactly the same way.

Use the AddEffect method of the Sequence to which you want to add an effect. This method requires you to specify the type of effect you want, and the shape you want to assign it to. You can also specify the following optional information:

  • For effects you assign to text boxes, charts, or diagrams, you can specify the build level (we discuss this in detail later in the article).
  • The event that triggers the effect, such as the user clicking a shape, or a set amount of time elapsing.
  • The effect's place in the sequence animation order.

The following table lists the parameters of the AddEffect method, and the object properties set by specifying those parameters.

Table 1. Parameters and Properties for the AddEffect method

AddEffect parameter Parameter data type Property set for Effect
Shape Shape object Effect.Shape
effectID MsoAnimEffect Effect.EffectType
Level (optional) MsoAnimateByLevel Effect.EffectInformation.
trigger (optional) MsoAnimTriggerType Effect.Timing.TriggerType
Index (optional) Long Effect.Index

Note that when you add an effect to an interactive sequence, you must specify an argument for the trigger parameter: either MsoAnimTriggerOnShapeClick, msoAnimTriggerAfterPrevious, or msoAnimTriggerWithPrevious. MsoAnimTriggerOnShapeClick is the only valid value for the first effect in an interactive sequence; the triggers msoAnimTriggerAfterPrevious and msoAnimTriggerWithPrevious are only valid if there is a previous effect in the interactive sequence. If left unspecified, the trigger parameter defaults to msoAnimTriggerOnPageClick, which is reserved for the main sequence and is therefore not a valid interactive trigger.

The following table lists the trigger type constants, and whether they are valid arguments for the trigger parameter.

Table 2. Trigger type contstants

MsoAnimTriggerType Valid trigger parameter for Main Valid trigger parameter for Interactive
MsoAnimTriggerAfterPrevious Yes Only if previous effect exists
MsoAnimTriggerMixed No No
MsoAnimTriggerNone No No
MsoAnimTriggerOnPageClick Yes No
MsoAnimTriggerOnShapeClick No Yes
MsoAnimTriggerWithPrevious Yes Only if previous effect exists

The following example adds an interactive sequence to a slide. The sequence consists of one shape that is not animated, but serves as a trigger for another shape when clicked by the user.

Dim objSequence As Sequence
Dim objShape1 As Shape
Dim objShape2 As Shape
Dim objEffect1 As Effect

With ActivePresentation.Slides(2)

    'Assign variables to shapes used in sequence
    Set objShape1 = .Shapes("Button")
    Set objShape2 = .Shapes("Arrow")
    With .TimeLine.InteractiveSequences
        'Add interactive sequence as first in collection
       Set objSequence = .Add(1)
       'Add effect for shape to fly in
       'when trigger shape is clicked
       With objSequence
        Set objEffect1 = .AddEffect(Shape:=objShape2, _
            effectId:=msoAnimEffectFly, _
        'Set trigger shape for effect
        objEffect1.Timing.TriggerShape = objShape1
       End With
    End With
End With

Another important aspect of the AddEffect method is that while it may actually generate more than one Effect object, it only returns a reference to the first Effect object it creates. This occurs when you specify build effects for text boxes, charts, or diagrams. Any other Effect objects created as part of a build effect are available in the Sequence.Effects collection, and follow the first effect for which the AddEffect method returned a reference. However, the Effect object contains no property to enable you to determine whether an effect belongs to a group of build effects created to animate the same shape.

Specifying Effects for Text, Charts, and Diagrams

Since we just mentioned that the AddEffect method may generate multiple Effect objects for build effects, let's take a moment and explain what build effects are.

While each text box, chart, or diagram is considered one shape, and represented in the object model as a single Shape object, you can apply effects that specify how you want the shape's sub-objects to combine, or build, to display the entire shape. For example, suppose you have a single text box that contains five bullet points. You can specify that each bullet point enter the slide individually, with different triggers, timing and entrance effects applied to each.

When you call the AddEffect method, you can specify the build level; this refers to the lowest level of sub-objects to which you want to assign the effect. For example, for a text box effect with a build level of msoAnimateTextBySecondLevel, each first and second level bullet point, or paragraph, is animated separately. Third, fourth, and fifth level paragraphs are animated at the same time as the second level paragraph above them.

The default argument for the Level parameter of the AddEffect method is msoAnimateLevelNone, which returns one Effect object for the entire shape. However, all other values (including msoAnimateTextByAllLevels, msoAnimateChartAllAtOnce, and msoAnimateDiagramAllAtOnce) add Effect objects for each sub-object. For example, the MsoAnimateTextByAllLevels parameter adds Effect objects for each paragraph in the text box, even though they are all animated at once. So for this example, while the Index property value for each Effect is different, they happen together.

The following code demonstrates this. It adds a new slide to the active presentation, adds text to that slide, and then sets the indent level for each paragraph. It then calls the AddEffect method to animate the text with a build level of msoAnimateLevelNone. This creates a single Effect object that animates the entire text box at once. The code writes out the sequence effect count and index, which are both one. The code then deletes the single effect and again calls the AddEffect method, this type passing a build level of msoAnimateTextByFirstLevel. This creates four Effect objects, one for each paragraph, even though the second-, third-, and fourth-level paragraphs are animated at the same time as the first level paragraph to which they belong. The code then writes out the sequence effect count, 4, the paragraph each Effect is assigned to, and the Index value of each Effect object.

Sub DemoBuildEffects()
Dim intSlideNumber As Integer
Dim objEffect As Effect

With ActivePresentation.Slides
    intSlideNumber = .Count + 1
    'Add new slide with a title and text placeholder
    .Add Index:=intSlideNumber, Layout:=ppLayoutText
    With .Item(intSlideNumber)
        For Each objShape In .Shapes
            'Identify the title place holder
            If objShape.PlaceholderFormat.Type = ppPlaceholderTitle Then
                objShape.TextFrame.TextRange.Text = "Build Effects Demo"
            'Indentify the text placeholder
            ElseIf objShape.PlaceholderFormat.Type = _
                ppPlaceholderBody Then
                With objShape.TextFrame.TextRange
                    'Insert four paragraphs of text
                    .Text = "This is the first level heading" & _
                    .InsertAfter "This is the second level heading" & _
                    .InsertAfter "This is the third level heading" & _
                    .InsertAfter "This is another first level heading"
                    'Set indent level of each paragraph
                    .Paragraphs(1, 1).IndentLevel = 1
                    .Paragraphs(2, 1).IndentLevel = 2
                    .Paragraphs(3, 1).IndentLevel = 3
                    .Paragraphs(4, 1).IndentLevel = 1
                End With
             With .TimeLine.MainSequence
                'Animate text as a single unit
                'adds one effect for all paragraphs
                Set efftextfly = .AddEffect _
                    (Shape:=objShape, _
                    effectId:=msoAnimEffectFly, _
                    trigger:=msoAnimTriggerOnPageClick, _
                Debug.Print "Animation Level None"
                Debug.Print "Effects: " & .Count
             End With
             For Each objEffect In .TimeLine.MainSequence
                Debug.Print "Index: " & objEffect.Index
            With .TimeLine.MainSequence
                'Delete previous effect
                'Animate text by first level
                'adds one effect for each paragraph
                'even those below first level
                Set efftextfly = .AddEffect _
                    (Shape:=objShape, _
                    effectId:=msoAnimEffectFly, _
                    trigger:=msoAnimTriggerOnPageClick, _
                Debug.Print "Animate First Level"
                Debug.Print "Effects: " & .Count
             End With
             For Each objEffect In .TimeLine.MainSequence
                'Print paragraph and index of each effect in collection
                Debug.Print "Paragraph: " & objEffect.Paragraph & _
                    "  Index: " & objEffect.Index

            End If
    End With

End With
End Sub

You can determine the paragraph in a text box to which a specified effect has been applied by using the Paragraph property of the Effect object.

To determine if a specified shape is a chart, diagram, placeholder or text box, use the Type property of the Shape object. This property returns an MsoShapeType constant, such as MsoChart, MsoDiagram, or MsoPlaceholder or MsoTextBox. Placeholder shapes contain a PlaceholderFormat child object, which in turn includes a Type property that identifies what kind of placeholder the shape is. Diagram shapes contain a Diagram child object, which contains properties specified to diagram shapes.

Assigning Indent Levels to Text

Because you assign build effects to a shape's text based on the indent levels of the text paragraphs, such as first-level, second-level, and so on, it's worth discussing how to specify the indent level for text.

Each Shape has a TextFrame object, which in turn has a TextRange object that contains all the text in that shape. You can then use various methods of the TextRange object to return other TextRange objects that represent various subset of the text in the shape, such as paragraphs, sentences, lines, runs, words, or characters. The IndentLevel property of a specified TextRange returns or sets the indent level assigned to that text.

You can specify one indent level per paragraph. If you assign an indent level to a text range that is a sub-set of a paragraph, such as a single sentence or character run, that indent level is applied to the entire paragraph. If you assign an indent level to a text range that encompasses text in multiple paragraphs, then each of those paragraphs is assigned the specified indent level. For example, if you change the indent level of a sentence, word, or run in a second-level paragraph to 3, then the indent level for the entire paragraph is set to 3.

Because the objects returned by the various TextRange methods are TextRange objects themselves, they have all the methods and properties of that type. For example, TextFrame.TextRange.Paragraphs.Count returns the number of paragraphs contained in a shape's text frame. Use the Paragraphs method to set the indent level of your paragraphs.

The following is excerpted from the code example above. It adds four paragraphs, or bullet points, to a shape on a slide. It then uses the Paragraphs method to individually return and set the indent level of each of those paragraphs.

With objShape.TextFrame.TextRange
  .Text = "This is the first level heading" & vbCrLf
  .InsertAfter "This is the second level heading" & vbCrLf
  .InsertAfter "This is the third level heading" & vbCrLf
  .InsertAfter "This is another first level heading"
  .Paragraphs(1, 1).IndentLevel = 1
  .Paragraphs(2, 1).IndentLevel = 2
  .Paragraphs(3, 1).IndentLevel = 3
  .Paragraphs(4, 1).IndentLevel = 1
End With


In this article, we discussed how a slide's timeline structure enables you to add multiple animation sequences per slide, and multiple animation effects to the shapes on the slide. We also examined how to programmatically add animation sequences and effects. In Animation Sequences in PowerPoint 2002 and PowerPoint 2003 (Part 2), we discuss a number of topics dealing with how to further customize your animation sequences and effects, including:

  • How to set the order in which effects are performed.
  • How to control the timing and triggers for your effects.
  • How to duplicate effects.
  • How to specifying effect behavior, including effects for audio and video files.
© 2014 Microsoft