11.2 Fancy features

Fancy features

Warning: the following features are fun to program and interesting to watch. However, the maxim "less is more" is very appropriate here. There is elegance in simplicity. Used sparingly, these features can set your presentation apart from others. Overuse them and the audience tires of all the gimmicks, leading them to ignore the slides and, quite possibly, the speaker who is presenting them. Remember, the audience sees only the presentation, not the way-cool tricks in your code.

Animations

Animations are special effects visual and audio that highlight important elements in a slide. Some animation effects that PowerPoint supports are objects flying in from the edge (choose your edge), text appearing letter-by-letter, and sound files playing. These animations can be timed to happen sequentially or all at once. They can happen automatically, or in response to mouse clicks. There are so many combinations and permutations of animations; we won t attempt to cover each and every one of them. The Animation dialog gives you an excellent interface in which to explore them. We ll give you an idea of what s possible to get you started.

There are 19 animation effects supported by PowerPoint 2000, many with several options, bringing the total number of effects to about 80. Figure 6 shows PowerPoint s Custom Animation dialog, with the Effects dropdown box shown open. This dialog also gives some insight into the available collections, objects, and properties. In the upper left corner, there is a list of all the objects on the slide; each can be animated separately (or not animated at all). The Effects tab is shown, displaying the many properties involved in customizing the effect. The other tabs indicate that there are properties to set the Order and Timing of effects, to animate Charts (if any are present), and to add Multimedia effects.

Figure 6. PowerPoint s Custom Animation dialog. The dropdown for Effects is open, showing many of the available animation effects.

The AnimationSettings object stores all the objects, collections, and properties that pertain to animations. The AnimationSettings object is stored in the AnimationSettings property of every Shape object. Shapes on the SlideMaster can be animated, too.

Setting the effect

The EntryEffect property sets the effect. This property is set to a numeric value, for which there are VBA constants. The constants are set up to combine the two fields in the dialog box describing what is to happen (shown in Figure 6 as "Fly") and any available options for that effect, such as where it might move from (shown in Figure 6 as "From Top-Left"). Some of the constants for the effects are: ppEffectAppear (3844), ppEffectFlashOnceFast (3841), ppEffectFlashOnceMedium (3842), ppEffectFlyFromLeft (3329), ppEffectFlyFromTopLeft (3333), ppEffectRandom (513), ppEffectZoomIn (3345), and ppEffectZoomInSlightly (3346). Use the Object Browser to look up the other 72 constants. See "Take me for a browse" in Chapter 2 for details on the Object Browser.

The following code sets the first shape on the slide to fly in from the left:

#DEFINE ppEffectFlyFromLeft 3329

oSlide.Shapes(1).AnimationSettings.EntryEffect = ppEffectFlyFromLeft

Modifying the effects

A very popular effect is to have a slide containing bulleted text, and have each of the bullets fly in from the left as the user clicks the mouse. A modification to the "fly in from left" effect is to set which levels of bullets fly in together. The TextLevelEffect tells which levels are animated. TextLevelEffect is set to a numeric value some of the constants are ppAnimateByFirstLevel (1), ppAnimateBySecondLevel (2), ppAnimateByAllLevels (16), and ppAnimateLevelNone (0). Setting the effect to animate the first level sends each first level bullet in separately, with all its subordinates. Setting the effect to animate the second level sends each first and second level item in separately any subordinates to the second level come in with their parent.

The following code generates an example Tasmanian Traders marketing slide, showing a bulleted list with two levels. The code sets the title and bullets to fly in from the left, one each time the mouse is clicked. The code is set to fly each of the bullets in separately (at level 2). Modify the code for a second run by changing the TextLevelEffect to ppAnimateByFirstLevel, to see that the first bullet flies in with its two subordinate bullets. Figure 7 shows the resulting slide.

#DEFINE ppEffectFlyFromLeft 3329

#DEFINE ppLayoutText 2

#DEFINE ppAnimateByFirstLevel 1

#DEFINE ppAnimateBySecondLevel 2

* Add a slide--title and text objects on the layout

oSlide = oPresentation.Slides.Add(1, ppLayoutText)

* Put in the title text and set the effect

WITH oSlide.Shapes[1]

.TextFrame.TextRange.Text = "Tasmanian Traders"

.AnimationSettings.EntryEffect = ppEffectFlyFromLeft

ENDWITH

* Put in some bullets (at 2 levels) and set the effect

m.BulletString = "Distributor of Fine Food Products" + CHR(13) + ;

"Beverages" + CHR(13) + ;

"Desserts" + CHR(13) + ;

"International Shipping" + CHR(13) + ;

"Satisfaction Guaranteed"

WITH oSlide.Shapes[2]

.TextFrame.TextRange.Text = m.BulletString

* Indents "Beverages" and "Desserts"

.TextFrame.TextRange.Sentences[2, 2].IndentLevel = 2

.AnimationSettings.EntryEffect = ppEffectFlyFromLeft

.AnimationSettings.TextLevelEffect = ppAnimateBySecondLevel

* Run this again, but change the TextLevelEffect constant in the line above

* to ppAnimateByFirstLevel to see how setting it to first level brings

* in the two "level 2" bullets with their "level 1" parent.

ENDWITH

Figure 7. An example of a bulleted list. Levels are used to format the bullets and text. Level 1 has a circular bullet. Level 2 has a dash for a bullet, and has slightly smaller text.

Automatic timing

To eliminate manual mouse clicks and let the show run automatically, use the AdvanceMode property. There are two constants: ppAdvanceOnClick (1) and ppAdvanceOnTime (2). When the AdvanceMode property is set to ppAdvanceOnTime, it checks the number of seconds stored in the AdvanceTime property. Add the following lines to the end of the previous example, and it automatically animates items one second apart.

#DEFINE ppAdvanceOnTime 2

* Change the Title shape's settings

WITH oSlide.Shapes[1].AnimationSettings

.AdvanceMode = ppAdvanceOnTime

.AdvanceTime = 1

ENDWITH

* Change the bullet text shape's settings

WITH oSlide.Shapes[2].AnimationSettings

.AdvanceMode = ppAdvanceOnTime

.AdvanceTime = 1

ENDWITH

If there are multiple shapes, the order in which the shapes are animated is set through the AnimationOrder property. By default, AnimationOrder is set to the creation order of the Shape (assuming, of course, that the Shape is to be animated at all). By setting the AnimationOrder property, you can change the order in which the objects are animated.

These are just a few of the many properties and methods available to animate shapes. See the Help file under "AnimationSettings Object" for a comprehensive list.

Transitions

Fades, dissolves, wipes; these are all various ways of transitioning between slides. Transitions can be applied to the SlideMaster, which affects all slides, or just to a single slide. The transitions are stored in the SlideShowTransition object. The SlideShowTransition object is similar to the AnimationSettings object transitioning to another slide is similar to transitioning a single object onto the screen.

The EntryEffect property is used to store the transition effect. It uses the same set of constants as the AnimationSettings EntryEffect property. Not all constants for EntryEffects are available for transitions, though (for example, ppFlyInFromLeft is only for animations).

Like AnimationSettings, the SlideShowTransition object has properties to advance automatically. The syntax is different than AnimationSettings, though. The SlideShowTransition object has an AdvanceOnTime logical property. The AdvanceTime property stores the number of seconds (just as in the AnimationSettings object).

The following code adds a transition to the first slide to "cover down" and automatically advance after two seconds. If this code were applied to the SlideMaster, it would affect every slide, but as written here, it only affects the first slide.

#DEFINE ppEffectCoverDown 1284

WITH oPresentation.Slides[1].SlideShowTransition

.EntryEffect = ppEffectCoverDown

.AdvanceOnTime = .T.

.AdvanceTime = 2

ENDWITH

Taking action

PowerPoint allows specific actions to be taken when the mouse is moved over or clicked on a shape. Actions include jumping to a specific slide in the slide show, running another slide show, running a separate program, playing a sound, as well as a few others. Figure 8 shows PowerPoint s interactive Action Settings dialog, which lists the possible actions.

Figure 8. PowerPoint s Action Settings dialog. Action settings define the action taken on mouse overs and mouse clicks.

The ActionSettings collection stores these actions. The collection contains two ActionSettings objects: one for a mouse click and one for a mouse over. The indices for the collections are ppMouseClick (1) and ppMouseOver (2).

The Action property is the property that controls the action. Set the Action property to one of the constants listed in Table 3.

Table 3. Where the action is. Set the Action property to determine the action taken when a user clicks on a shape.

Constant

Value

Constant

Value

ppActionNone

0

ppActionHyperlink

7

ppActionNextSlide

1

ppActionRunMacro

8

ppActionPreviousSlide

2

ppActionRunProgram

9

ppActionFirstSlide

3

ppActionNamedSlideShow

10

ppActionLastSlide

4

ppActionOLEVerb

11

ppActionLastSlideViewed

5

ppActionPlay

12

ppActionEndShow

6

   

The following code adds an arrow shape in the lower right corner of a slide, and sets its Action property to move to the previous slide.

#DEFINE msoShapeRightArrow 33

#DEFINE ppMouseClick 1

#DEFINE ppActionPreviousSlide 2

oShape = oSlide.Shapes.AddShape(msoShapeRightArrow, 600, 450, 50, 50)

oShape.ActionSettings[ppMouseClick].Action = ppActionPreviousSlide

PowerPoint has a feature called Action Buttons, which are a series of predefined buttons. These buttons have a consistent look, and they help the presentation designer maintain a consistent look and feel. When entered interactively in PowerPoint, the dialog box comes up with the Action defaults for the type of button selected. For example, placing the button with the End picture on it sets the Action default to jump to the end of the slide show. When these buttons are added in code (Automation or VBA macros), no default Action is specified you must specify it explicitly using code like that shown previously.

The ActionSettings collection has additional properties to support other kinds of Actions. To enter a hyperlink, first set the Action property to ppActionHyperlink, then set the properties of the Hyperlink object. To create a hot link, set the Address property of the Hyperlink object, which stores the URL. Here s a code sample that adds a shape and attaches a hyperlink to a URL.

#DEFINE msoShapeRectangle 1

#DEFINE ppMouseClick 1

#DEFINE ppActionHyperlink 7

oShape = oSlide.Shapes.AddShape(msoShapeRectangle, 300, 200, 150, 100)

WITH oShape.ActionSettings[ppMouseClick]

.Action = ppActionHyperlink

.Hyperlink.Address = "http://www.hentzenwerke.com"

ENDWITH

You can even run any program, including compiled FoxPro programs, from a mouse click or mouse over. This is accomplished through the Run method. Pass it the fully qualified program name.

#DEFINE msoShapeRectangle 1

#DEFINE ppMouseClick 1

oShape = oSlide.Shapes.AddShape(msoShapeRectangle, 300, 200, 150, 100)

oShape.ActionSettings[ppMouseClick].Run = ;

"C:\Program Files\Microsoft Office\Office\WINWORD.EXE"

 

Copyright 2000 by Tamar E. Granor and Della Martin All Rights Reserved



Microsoft Office Automation with Visual FoxPro
Microsoft Office Automation with Visual FoxPro
ISBN: 0965509303
EAN: 2147483647
Year: 2000
Pages: 128

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net