Microsoft Office Tutorials and References
In Depth Information
17.1.2 Close Method
Enum XlWBATemplate
xlWBATWorksheet = -4167
xlWBATChart = -4109
xlWBATExcel4MacroSheet = 3
xlWBATExcel4IntlMacroSheet = 4
End Enum
In this case, the new workbook will contain a single sheet of the specified type. If the Template
argument is omitted, Excel will create a new workbook with the number of blank sheets set by the
Application object's SheetsInNewWorkbook property.
17.1.2 Close Method
The Close method closes all open workbooks. The syntax is simply:
WorksbooksObject .Close
17.1.3 Count Property
Most collection objects have a Count property, and the Workbooks collection is no exception.
This property simply returns the number of currently open workbooks.
17.1.4 Item Property
The Item property returns a particular workbook in the Workbooks collection. For instance:
returns the Workbook object associated with the first workbook in the Workbooks collection.
Since the Item property is the default property, we can also write this as:
Note that we cannot rely on the fact that a certain workbook will have a certain index. (This
applies to all collections.) Thus, to refer to a particular workbook, you should always use its name,
as in:
It is important to note that if a user creates a new workbook named, say, Book2, using the New
menu item on the File menu, then we may refer to this workbook in code by writing:
but the code:
will generate an error (subscript out of range) until the workbook is actually saved to disk.
17.1.5 Open Method
This method opens an existing workbook. The rather complex syntax is:
Search JabSto ::

Custom Search