Microsoft Office Tutorials and References
In Depth Information
Explore the Excel Object Model
Explore the Excel
Object Model
To program Excel with VBA, you need to
understand the Excel object model.
In the programming lexicon, an object model is
a complete summary of the objects associated
with a particular program or feature, the
hierarchy used by those objects, and the
properties and methods supported by each
object. Here an object is a distinct, manipulable
item such as a worksheet or range; a property is
a programmable characteristic of an object
such as a worksheet’s name or whether a range
is formatted with bold text; and a method is an
action you can perform on an object, such as
creating a new worksheet or clearing the
formatting from a range.
This section shows you a few properties and
methods for the three main objects in the
Excel model: the workbook, the worksheet,
and the range.
Workbook Object
You can use VBA to create new workbooks, open, save, and close workbooks, and more. You can
reference a specific workbook either by using the ActiveWorkbook object, which represents the
workbook that currently has the focus, or by using the Workbooks collection, which represents all
the workbooks currently open in Excel. Here are some examples:
Workbooks(1)
Workbooks(“Budget.xlsx”)
Workbook Properties
Property
Description
Name
Returns the filename of the workbook.
Path
Returns the location of the workbook.
FullName
Returns the location and filename of the workbook.
Saved
Returns False if the workbook has unsaved changes.
Workbook Methods
Method
Description
Add
Creates a new workbook.
Open
Opens an existing workbook.
Save
Saves a workbook.
Close
Closes a workbook.
 
Search JabSto ::




Custom Search