Word Document Properties


Chapter 2: Your First VBA Program



Download 8,82 Mb.
Pdf ko'rish
bet43/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   39   40   41   42   43   44   45   46   ...   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 35


Step 2: Implement the design
The wording for this step is just a fancy way of saying that you need to write
some code. You often hear programmers use the phrase “implement the
design,” and it also appears as commonly used jargon in many magazines.
Before you can write some code, you need to open the Visual Basic Editor in
older versions of Office by using the Tools

Macro

Visual Basic Editor com-
mand. When working with Office 2007, all you need to do is click Visual Basic
the Developer tab on the Ribbon. I’m using Excel for this example, but the
same steps work in Access, Word, FrontPage, PowerPoint, and most other
applications that support VBA. The only change is that your screen shots
won’t look precisely like mine when you use another product.
The first thing to do is create a Code window. To do that, use the Insert

Module command. The Visual Basic Editor creates a blank Code window
where you can type your program. A blank Code window can be a scary 
experience, but you don’t need to worry because you already have some text
(the code snippet in the previous section, “Step 1: Design the program”) to
put into it. The Code window is a kind of container (an editor) where you
create a 
Sub
(or sub-procedure). The 
Sub
contains your pseudo-code and,
eventually, the code you write to implement the pseudo-code. (Chapter 3
describes the 
Sub
in detail, so you don’t need to worry about it for now.)
Add a single-quote character (

) in front of each pseudo-code statement to
ensure that VBA knows that this is pseudo-code. All VBA comments begin
with a single quote. Figure 2-1 shows how your Code window should look.
You can run the 
Sub
shown in Figure 2-1, but it doesn’t do anything. To make
this example do something, add to it some code that VBA understands.
This means converting the English statements, such as “Display the message
box,” into VBA. To display a message box, use the 
MsgBox
function, which I
describe in Chapter 1.
Figure 2-1:
The Code
window
starts blank,
but you
already have
information
to add to it.
36

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   39   40   41   42   43   44   45   46   ...   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