Powerful PowerPoint for Educators: Using Visual Basic for Applications to Make PowerPoint Interactive


Download 1.37 Mb.
Pdf ko'rish
bet133/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   129   130   131   132   133   134   135   136   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

Sub GetObjectName()
MsgBox (ActiveWindow.Se 
lection.ShapeRange.Name)
End Sub
Sub SetObjectName()
Dim objectName As String
objectName = InputBox(prompt:="Type a name for the ob 
ject")
objectName = Trim(objectName)
If objectName = "" Then
MsgBox ("You did not type any 
thing. The name will re 
main " & _
ActiveWindow.Se 
lection.ShapeRange.Name)
Else
ActiveWindow.Se 
lection.ShapeRange.Name = objectName
End If
End Sub
If you try to run either of these pro cedures with out hav ing one ob ject selected,
you will get an er ror message. If you try to give an ob ject the same name as an-
other ob ject on that slide, you will also get an er ror message, so be sure to give
each object on a slide a different name.
Because these procedures run in Edit View in PowerPoint (not from Slide
Show View or from the VBA Ed itor), we cannot create a but ton on a slide to run
them. The eas iest way to run a script in Edit View is to se lect “Macro” from the
Tools menu and choose “Macros” from the flyout menu (or hit Alt-F8 on a Win -
dows computer or Op tion-F8 on a Macintosh). Se lect the procedure name that
you want to run, and click on the Run but ton (see Figure 8.1).
Figure 8.1. Run ning a Macro in Edit View
132 More Tricks for Your Scripting Bag


Slide Names
Just as ob ject num bers can change, slide num bers can change as well. If you 
are try ing to go to a par ticular slide and you use a slide num ber, you might have a 
problem if you de lete or in sert slides before that slide. Slide names never change
unless you change them. When a slide is created, it is as signed a name (Slide1,
Slide2, Slide3, etc.). These names are as signed in the order the slide is in serted,
not the order in which the slide is within the pre sentation. For ex ample, if you
create a slide, it will be named “Slide1.” If you cre ate an other slide, it will be
named “Slide2.” If you create a third slide be tween “Slide1” and “Slide2,” it will
be the second slide in the presentation, but it will be named “Slide3.”
If you move slides around a lot, you will have a hard time re membering
their names. Use 

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   129   130   131   132   133   134   135   136   ...   191




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling