Wednesday, November 2, 2011

Workbooks Fundamentals

In the VBA language, a workbook is an object that belongs to a collection called Workbooks. Each workbook of the Workbooks

collection is an object of type Workbook, which is a class.

Each workbook of the Workbooks collection can be identified using the Item property. To programmatically refer to a workbook,

access the Item property and pass either the index or the file name of the workbook to it.

After referring to a workbook, if you want to perform an action on it, you must get a reference to it. To do this, declare a

Workbook variable and assign the calling Item() to it. This would be done as follows:

Private Sub cmdSelectWorkbook_Click()
Dim SchoolRecords As Workbook

Set SchoolRecords = Workbooks.Item(2)
End Sub

No comments: