As you
keep track of more things, you will set up more things in the
Ini
tial
ize
pro cedure. This will in clude more ob jects that might be hid den or
shown and vari ables, like ones to store the num ber of correct and in correct an -
swers that need to be given ini tial val ues. You’ll see more about this in Chapter 7
when we start keeping score.
Finally, ty ing this all together, slides 2 and 3 will
need but tons to show the
stars. These but tons might be the right an swer but tons on those slides. For exam-
ple, the right an swer on slide 2 might be linked to
Sub RightAnswerTwo
ActivePresentation.Slides(2).Shapes(4).Vis
ible = True
End Sub
Other things could happen in the
RightAnswerTwo
pro cedure,
such as add ing
one to the num ber of correct an swers or putting up a
MsgBox
, but un til we get to
Chapter 7, a star with the text “Good job” will be enough.
Figure 6.2 shows the VBA script and slides for this example. The arrows
show which but ton should be con nected to which pro cedure. The stars are show -
ing
in the fig ure, but they will be hid den in the
GetStarted
pro ce dure and
shown when the cor rect an swer is chosen.
Figure 6.2. Sim ple Quiz Show ing Stars for Correct An swers
70 A Scripting Bag of Tricks
Ref er enc ing Ob jects by Num ber
In the above ex ample, we hid and showed shape num ber 4 on slide number
2. You might be asking, “How do I know what the shape number is? I want to
hide
that star, and I don’t know what number it is.” The number of an ob ject gen -
erally is the or der in which it was added to a slide. If you start with a blank slide
and add a text box, a
rectangle, and a but ton (in that or der), the
text box will be
shape num ber 1, the rectangle will be shape num ber 2, and the but ton will be
shape num ber 3. If you start with a slide that is not blank, the existing shapes will
count. So, if you start with a bulleted list slide (known as a “Ti tle and Text” slide
in PowerPoint 2002) and add the text box, rectangle, and button,
• the slide ti tle will be shape num ber 1,
• the bulleted list text area will be shape num ber 2,
• the text box you added will be shape num ber 3,
• the rectangle will be shape num ber 4, and
• the but ton will be shape number 5.
This is fine, but most of us don’t have su perhuman memories that can re-
member what or der shapes were added. For PowerPoint ver sions 97, 98, 2000,
and 2001, finding the number is easy. While look ing at a slide, go to the Slide
Show menu and choose “Custom Animation.” Click on the “Timing” or “Order
& Timing” tab, as shown in Figure 6.3.
Do'stlaringiz bilan baham: