Word Document Properties


Chapter 2: Your First VBA Program



Download 8,82 Mb.
Pdf ko'rish
bet46/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   42   43   44   45   46   47   48   49   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Chapter 2: Your First VBA Program
06_046500 ch02.qxp 12/5/06 5:33 PM Page 39


Four Ways to Run Your Program
Running your program from within the Visual Basic Editor is fine when you want
to test it. However, the goal is to run it from the application and not have to
open the Visual Basic Editor first. You have a lot of choices for running any
VBA program — more than most people want to remember. VBA provides
four common methods for running applications, but most VBA users never
need to think beyond the first method, which is using the Macro dialog box.
Using the Macro dialog box
The Macro dialog box is the most common way to run a VBA program. Every
time that you create a new 
Sub
, it appears in the list of macros that you can
run. You don’t have to do anything special. This feature means that you can
always access every program that you create by using this method, which is
why it’s the most popular method.
When working with older versions of Office, use the Tools

Macro

Macros
command to display the Macro dialog box. When using newer versions of
Office, click Macros on the Developer tab on the Ribbon to display the Macro
dialog box, as shown in Figure 2-5. You can also display this dialog box by
pressing Alt+F8 in Office applications. (Other applications use different key
combinations.) Notice that Figure 2-5 shows the macro, 
SayHello
, that
appears in the earlier “Step 2: Implement the design” section of this chapter.
When you want to run the program, highlight it and then click the Run button.
Try it now. You should see the same two dialog box sequences that you saw
when you tested the program earlier in this chapter.
40
Part I: An Overview of VBA 
The origins of computer bugs
You might wonder why professionals call a pro-
gramming error a 
bug. There are many versions
of this story, but all of them begin in the early
annals of computer history. At that time, com-
puters were immense devices that could take up
an entire building. Instead of the small chips used
in today’s computers, these older devices used
switches and vacuum tubes. The story holds
that one day a programmer of one of these mas-
sive machines experienced an error. After a
long search, the programmer found an actual
bug in one of the switches used to control the
computer. The term stuck — all programming
errors are now blamed on insects.
06_046500 ch02.qxp 12/5/06 5:33 PM Page 40


You can also use this dialog box to perform other tasks. Highlight the macro
name, and then click the Edit button; the application opens the Visual Basic
Editor. The Code window displays the code associated with the program that
you highlighted. You can also remove old programs by clicking the Delete
button.
Notice the Macro Name field near the top of the Macro dialog box shown in
Figure 2-5. This field normally contains the name of the macro that you’ve
highlighted in the list. However, you can also use the Macro dialog box to
create new programs. Type 

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   42   43   44   45   46   47   48   49   ...   207




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

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish