We’ve seen some of the syntax and structure of the VBA language. Next we need to examine the Word VBA developer’s environment, the window where you create and modify code. Like the other Office applications, Word uses the Visual Basic Editor as its development environment.
To launch the editor, select Tools → Macro → Visual Basic Editor in a Word window, or hit Alt-F11. The Microsoft Visual Basic window opens, looking something like Figure 18-5.
Figure 18-5. The Visual Basic Editor in Word
The major components of the VBA window are:
Project Explorer. Lists the open projects (templates and documents), with folders for their objects, references, forms and modules.
Immediate Window. Lists statements printed from code using
Properties Sheet. Lists the properties of the selected object (in this case, a UserForm).
Code Window. Shows the code in a module.
UserForm. Shows a UserForm in design view.
Object Browser. Shows the components of the selected object library.
Project Explorer window
(the Project-TemplateProject window in Figure 18-5)
contains open projects, displayed in a tree structure.
editor, a “project” is any open document (including
templates). In Figure 18-3,
normal.dot (which doesn’t show in the
figure), a document named
Chapter 18, another
Document2, and ...