Share this Page URL

The VBA Editor in Word > The Project Explorer and Properties Window - Pg. 433

ment, without having to select it. While there can be only one Selection object in a Word document, there can be multiple Range objects, which makes them more flexible. Other than that, Range and Selection objects share a great many properties and methods, and can be used in a similar manner. For a detailed discussion of the Range and Selection objects and their use in VBA code, see Writing Word Macros, by Steven Roman (O'Reilly & Associates). The entire object model is far too large to cover here. But you can get a good feeling for how to control Word by examining some of its major objects: Application, Document, Range, and Selection. (For full details on all objects and their methods and properties, consult the Word VBA help available through the VBA editor or the object model diagram.) The VBA Editor in Word 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. The major components of the VBA window are: