Microsoft Office Tutorials and References
In Depth Information
To create a new Wo rkbook event procedure, follow these steps:
Double-click the ThisWorkbook object to activate it.
Click the Object drop-down list, and select the Workbook option.
Click the Procedure drop-down list, and select the desired event.
In Figure 12-2, the Visual Basic Editor displays the Procedure drop-down list while creating
a new Wo rkbook event procedure.
Figure 12-2. The VB Editor is the best way to create a new event procedure.
After you have created the new event procedure, you’ll notice the Private Sub
Workbook_Event and End Sub lines have been added to the code window. Now that you’ve
created the event procedure’s framework, you can to add the code to be executed when the
event is triggered. Table 12-1 describes the commonly used events that can be attached to the
Table 12-1. Commonly Used Workbook Events
Action That Triggers the Event
Monitors the Open event for a workbook. The event is triggered
when the workbook or add-in is opened and executes the
Monitors the Activate event for a workbook. The event is triggered
whenever the workbook is activated.