Wednesday, November 2, 2011

Microsoft Excel as an MDI

To support the ability the programmatically access a workbook, the Workbook class is equipped with a method named Activate.

Its syntax is:

Workbook.Activate()This method takes no argument. Therefore, to call it, you can get a reference to the workbook you want to

access, then call the Activate() method. Here is an example:

Private Sub cmdSelectWorkbook_Click()
Dim SchoolRecords As Workbook

Set SchoolRecords = Workbooks.Item(2)
SchoolRecords.Activate
End SubYou can also do this with less code by applying the index directly to the Workbooks collection. Here is an example:

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

No comments: