Word Document Properties


Module, class module, and form



Download 8,82 Mb.
Pdf ko'rish
bet55/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   51   52   53   54   55   56   57   58   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Module, class module, and form:
These three elements act as containers
for main programming elements such as class descriptions and proce-
dures. A single project can have multiple modules, class modules, and
forms in it. However, each of these elements requires a unique name.
Function
and 
Sub
:
The 
Function
and 
Sub
elements hold individual
lines of code (also called 
statements
). A 
Function
returns a value to the
caller, but a 
Sub
does not. Microsoft Office provides access to code func-
tionality through the 
Sub
, not through the 
Function
. Consequently, you
must always provide access to your VBA program by using a 
Sub
.
Statement:
Many people call an individual line of code a 
statement.
The pseudo-code in Chapter 2 shows why. Each line of pseudo-code is a
statement of what the application should do. The example in the “Step 2:
Implement the design” section of Chapter 2 shows how these lines of
pseudo-code are translated into code that VBA can understand. You’re
still making a statement when you use VBA code to perform a task —
you’re just doing it in VBA’s language.
53
Chapter 3: Writing Structured VBA Programs
08_046500 ch03.qxp 12/5/06 5:34 PM Page 53


Using the Macro Recorder
The Macro Recorder lets you record keystrokes and actions that you perform
as a VBA program. You can use it to record complete tasks, such as setting up
a document, or for partial tasks, such as highlighting text and giving it certain
attributes. The Macro Recorder can help you perform the following tasks:
Create a macro based on your actions.
Discover how Word performs certain tasks.
Decide how to break your program into tasks.
Help you create the basis for a more complex program.
The Macro Recorder isn’t a complete solution for your VBA needs. For exam-
ple, you can’t use the Macro Recorder to create interactive programs without
extra coding. The same holds true for programs that must change based on
user input, the environment, or the data you’re manipulating. All of these
tasks require you to add more code. However, it’s a good starting point for
many structured programming tasks. You can get the basics down quickly
using the Macro Recorder and then make changes as needed. The macro
recording process follows the same basic steps no matter which version of
Office you use:
1. Start the Macro Recorder.
2. Perform all of the steps that you normally perform to accomplish a task.
3. Stop the Macro Recorder.
4. Save the macro when the Office application prompts you.
5. Optionally, open the resulting macro and make any required changes.
Recording a macro using the Ribbon interface
Recording a macro with the new features provided by the Office 2007 Ribbon
interface is easier than in past versions. Microsoft has added features that
reduce the complexity of creating a macro. For example, when you press Alt,
you see the number or letter you must press to perform a particular action in
little boxes over each control on the Ribbon.
If you’re used to using the mouse to perform most Office tasks, you may want
to practice the keystrokes you need to use to record the macro several times.
Recording the macro without mistakes makes it run faster and also makes it
easier to edit the recorded macro later. The following steps describe how to
record a macro using the Ribbon interface:
54

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   51   52   53   54   55   56   57   58   ...   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