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


Getting Started with VBA In tro duc tion


Download 1.37 Mb.
Pdf ko'rish
bet37/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   33   34   35   36   37   38   39   40   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

4
Getting Started with VBA
In tro duc tion
In pre vious chapters you learned some basic features of PowerPoint and
what VBA is. This chapter shows you how to access the VBA Ed itor, how to
write simple scripts in VBA, how to at tach those scripts to but tons and ob jects,
and how to pro tect your scripts with a password. When you have completed this
chapter, you will know the me chanics of writing a script and us ing it in a
PowerPoint presentation, and you will be ready to learn how to do some in terest-
ing things with VBA.
Vo cab u lary
• Ac tion set tings
• Mod ule
• Add Text

MsgBox
• But ton
• Pass word
• Macro
• Vi sual Ba sic Ed i tor
Ac cess ing the VBA Ed i tor
Once you start a PowerPoint pro ject, you get into VBA by hold ing down
the ALT key and hit ting the F11 key (op tion-F11 on a Macintosh). Al terna-
tively, go to the Tools menu, choose “Macro,” and choose “Vi sual Ba sic Ed i tor”
from the flyout menu. At this point, you should see two small windows on the


left (the Project win dow and the Prop erties win dow) and a large blank area on
the right of the screen. Choose “Mod ule” from the In sert menu, and you will get
a window in the blank area (see Fig ure 4.1). The window prob ably will be
named “Module1.” This is where you will write your procedures.
Figure 4.1. In sert Module1
While we are here, let’s write one. Type the fol lowing:
Sub SayHello()
MsgBox("Hello")
End Sub
Note that the com puter will type the “End Sub” for you. Now go to the Run
menu, and se lect “Run Sub/UserForm.” You should get a message box that says
Hello (see Fig ure 4.2).
Fig ure 4.2.
MsgBox
Says “Hello”
42 Getting Started with VBA


Congratulations! You have just written and ex ecuted your first VBA pro ce-
dure. Click the OK but ton, and you can do some more.

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   33   34   35   36   37   38   39   40   ...   191




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