Word Document Properties


Part II: Learning the Ropes



Download 8,82 Mb.
Pdf ko'rish
bet67/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   63   64   65   66   67   68   69   70   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Part II: Learning the Ropes 
08_046500 ch03.qxp 12/5/06 5:34 PM Page 66


Creating an application plan
In Chapter 2, I describe how to use pseudo-code to write a program. The pro-
gram in that chapter uses only one module because it’s quite simple. Not
every program that you create is that simple. Sometimes a program performs
complex tasks, and you need to create an 
overview,
or 
application plan,
first.
Think of the Lego approach again: Each block is separate, but you don’t get
the whole picture until you put the blocks together. The application plan
shows how to put the blocks together to get a particular result. You have
three sizes of blocks that you can use:
Projects
Modules, forms, and class modules
Sub-procedures and functions
Think about the writing of a VBA program this way: You have a pile of
blocks, and you have a picture of what you want to create in your mind.
To make the creation a reality, you choose and add blocks that look like
they fit. You can choose standard blocks from this book, the VBA help 
file, or online sites, such as FreeVBCode.com at 
http://www.
freevbcode.com/
.
You can use a number of techniques to create your application plan. I usually
start with a list of major tasks, such as printing a report or finding a word.
This isn’t pseudo-code. You’re not writing a procedure for VBA to follow.
All that you’re thinking about are the major tasks that VBA has to perform.
Maybe your program performs only one major task. In that case, you might
be able to get by with a single project, module, and sub-procedure, like in the
example in Chapter 2.
67
Chapter 3: Writing Structured VBA Programs
Understanding the Lego approach
I call the method that I describe in this chapter 
the
Lego approach because most people are familiar
with this toy and it’s an easy way to explain good
programming technique. Some people use other
names for this kind of programming. You might
hear it called 
modular programming, for example,
because it relies on modules to hold individual
pieces of code. Don’t confuse all these terms with
object-oriented programming, which I describe
in Chapter 8.
08_046500 ch03.qxp 12/5/06 5:34 PM Page 67


Defining the project
You may never need to define more than one project for a program. This is espe-
cially true of Access and Excel projects, in which everything needed to hold
the data appears in one file in most cases. You can also place everything that
you need into a single Word template if this is the only template that you
need and the program is appropriate for use with more than one document.
However, think about Word for a moment, and you discover something about
projects. Figure 3-9 shows a typical Project Explorer window setup. Notice
that this window contains three projects: Normal, Project (Document1), and
TemplateProject (LETTER).
Word always loads the Normal template. (This template can have one of a
number of different extensions, including DOT, DOTX, and DOTM in Office
2007.) Older versions of Word always use the Document Template (DOT)
extension. Word 2007 can also use Microsoft’s new XML format (DOTX) or
macro-enabled format (DOTM). If you want to create macros for Word 2007,
the best file format to use for compatibility is the DOT file, but you get the
greatest flexibility and feature set by using the DOTM file. You can’t store
macros in the DOTX file.
You can also use a custom template. Custom templates contain special for-
matting and macros for a particular document type, such as a letter. As with
the Normal template, custom templates come with DOT, DOTX, and DOTM
extensions. You can never store macros in a DOTX file.
Finally, you also have the document, which also counts as a project. A docu-
ment can have a DOC, DOCX, or DOCM file extension. You can store macros
only in the DOC and DOCM file formats. In this case, I wrote a program for
the individual document that uses template-specific sub-procedures and

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   63   64   65   66   67   68   69   70   ...   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