Datasheet

Book IX
Chapter 1
Automation with Other
Office Programs
667
Using Object Libraries
Exploring an object library
After adding a reference to a program’s object model, you can explore that
program’s objects, properties, and methods through the Object Browser.
In the Visual Basic Editor, choose ViewObject Browser from the Visual
Basic Editor menu or press F2. When you open the Object Browser, it shows
the objects for everything VBA has access to. To limit the list to a specific
library, choose the library’s name from the Project/Library drop-down list in
the top-left corner of the Object Browser window. In Figure 1-2, we selected
Excel to show only the classes and members related to Microsoft Excel.
Figure 1-2:
Use the
Object
Browser
to view a
program’s
object
model.
Each application exposes a lot of objects to VBA — way too many for you (or
any sane person) to remember. We don’t have enough room in this book to
define every property and every method for each Office application. We’d
probably need a book just for each application, which wouldn’t make too
many trees very happy, would it? Instead, you have to be able to get the
information you need when you need it.
To find out more about a selected object, property, or method in the Object
Browser, click the Help icon — the yellow question mark — in the Object
Browser window.
The Application object
Each application exposes (makes available) its own set of objects to VBA,
but one object that each application has in common is the Application
object. The Application object exposes that program’s objects, proper-
ties, and methods to VBA. When a program is open, its objects are available
44_532188-bk09ch01.indd 66744_532188-bk09ch01.indd 667 3/29/10 10:59 PM3/29/10 10:59 PM