Page 60 - Excel Progamming Weekend Crash Course
P. 60
d540629 ch03.qxd 9/2/03 9:27 AM Page 35
Session 3 — The Excel Object Model 35
The Object Hierarchy
The Excel object model is organized in a hierarchy. At the top of this hierarchy is the
Application object that represents the Excel application itself. All other objects in the
Excel object model are subsidiary to Application. The Application object is always avail-
able to your code.
If you were writing VBA code in another Office program, such as Word, and
needed to program Excel, you would need to explicitly create the Excel
Note Application object. That, however, is beyond the scope of this book. When
you are programming within Excel, the Application object is always avail-
able as an implicit reference.
The Workbook object has several immediate children, the most important of which is the
Workbooks collection. This collection contains one Workbook object for each open work-
book. Each Workbook object has a Sheets collection, which contains one Sheet object for
each worksheet or chart sheet that the workbook contains. Figure 3-1 illustrates the struc-
ture of the object model as described so far.
Application = Object
= Collection
Workbooks
Workbook
Sheets
Sheet
Figure 3-1 The relationships between the Application, Workbook, and Sheet
objects
Needless to say, the Excel object model is much more complicated than this diagram
might suggest. There are many other objects and collections not shown here that are cov-
ered in later sessions.