Using the Object Browser

Learning the nuances of VBA can be as difficult as learning the details of any human language. Fortunately, VBA includes an extremely thorough dictionary that lists all valid commands. Granted, the dictionary doesn't have descriptions of what all those commands mean, but you can often deduce those meanings by seeing the commands themselves.

Microsoft calls the giant dictionary an object browser, and it opens up the entire world of object models—not just the ones for Office and your favored variety of VBA, but for any program that can be called from VBA, using the CreateObject() function.

To use the VBA Object Browser

  1. Select the programs you want to browse by choosing Tools, References (see Figure 41.7).

    Figure 41.7. Check the box for any application you might want to manipulate from VBA, either with programs inside the Office application itself, or via the CreateObject() function.

  2. Press F2 to display the Object Browser (see Figure 41.8).

    Figure 41.8. The Object Browser brings up an exhaustive list of all the valid components of the underlying object model.

  3. Select the application that interests you in the Library box, and all the valid commands for that application appear. You can even look for a specific word or string of characters, by typing them in the Search box and clicking the Search button.

If you double-click an object, all the valid properties, methods, and events associated with the object appear on the right. In Figure 41.8, Document.Close shows up as a valid Object.Method pair, and its parameters appear at the bottom of the screen. Choose an object, property, method, or event and press F1 to see context-sensitive help.

To dismiss the Object Browser, press F7 or choose View, Code.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.33.157