Microsoft Office Tutorials and References
In Depth Information
Getting Acquainted with Workbook-Level Events
Event
Action That Triggers the Event
Deactivate
A workbook is deactivated.
NewChart
A chart has been created.
NewSheet
A new sheet is created in a workbook.
Open
A workbook is opened.
SheetActivate
Any sheet is activated.
SheetBeforeDoubleClick
Any worksheet is double-clicked. This event occurs before the default
double-click action.
SheetBeforeRightClick
Any worksheet is right-clicked. This event occurs before the default
right-click action.
SheetCalculate
Any worksheet is calculated (or recalculated).
SheetChange
Any worksheet is changed by the user or by an external link.
SheetDeactivate
Any sheet is deactivated.
SheetFollowHyperlink
A hyperlink on a sheet is clicked.
SheetPivotTableUpdate
A pivot table is changed or refreshed.
SheetSelectionChange
The selection on any worksheet is changed.
WindowActivate
Any workbook window is activated.
WindowDeactivate
Any workbook window is deactivated.
WindowResize
Any workbook window is resized.
If you need to monitor events for any workbook, you need to work with Application -
level events (see “Monitoring with Application Events,” later in this chapter). The
remainder of this section presents examples of using Workbook -level events. All the example
procedures that follow must be located in the code module for the ThisWorkbook
object. If you put them into any other type of code module, they won’t work.
The Open event
One of the most common events that is monitored is the Open event for a workbook. This event
is triggered when the workbook (or add-in) is opened and executes the procedure named
Workbook_Open . A Workbook_Open procedure is often used for tasks such as these:
h Displaying welcome messages.
h Opening other workbooks.
h Setting up shortcut menus.
h Activating a particular sheet or cell.
h Ensuring that certain conditions are met. For example, a workbook may require that a
particular add-in is installed.
 
Search JabSto ::




Custom Search