Wednesday, November 2, 2011

Viewing Many Workbooks

To programmatically refer to a workbook, access the Item property and pass either the index or the file name of the workbook

to it. Here is an example:

Private Sub cmdSelectWorkbook_Click()
Workbooks.Item (2)
End Sub


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: