You don't need to understand how the Word object model fits together in order to work with VBA in Word, but most people find having a general idea of the object model helpful. To see the object model, follow these steps:
Launch or activate Word, and then press Alt+F11 to launch or activate the Visual Basic Editor.
Choose Help Microsoft Visual Basic Help MSDN on the Web.
In the Live Search textbox, type Word 2007 object model map .
In the list of search result links, click Word Application Object Model Map [Word 2007 Developer Reference]. Or you can enter this URL in the address field of your Internet browser: http://msdn2.microsoft.com/en-us/library/bb288731.aspx. You'll see the object model in your Internet browser (see Figure 20.1).
At this point you might want to add this web page to your Favorites, Bookmarks, or Links. This page is your gateway into the object model.
You can see the object model map in the regular (offline) Help screen, but it's a convoluted process getting to it. You might see a link to "Word object model maps" in the Help system, but the link is currently dead. More important, the online (MSDN) version of the map includes some useful features, such as the left pane table of contents and greater flexibility in general. (True, you can click the purple book icon on the Visual Basic Editor's Help window's toolbar to display a table of contents in a left pane, but in general the online help system is not only superior and can also be updated more easily.)
When you look at the Word object model on your screen, you'll see that some of the boxes are shaded yellow, while the others are shaded blue. The yellow boxes are collection objects, while the blue objects are not collections. Boxes with red stars are objects or members new in Office 2007.
Click a box to see the help screen for the object, often including useful code examples you can study or copy into your own VBA procedures.
Figure 20.2 shows part of the Help screen for the RecentFiles collection, which contains details of the files in the Most Recently Used list (the list that appears when you click the Office button).
The following sections show you how to work with some of these objects, starting with the Documents collection and the Document object. You'll see how to use the ActiveWindow object and the Windows collection in the next chapter.
3.141.7.174