Microsoft Office Tutorials and References
In Depth Information
Figure 11-2. Application-level events
SheetDeactivate
Occurs when any sheet is deactivated.
Occurs when the selection changes on any
worksheet (does not occur if the selection is on a
chart sheet).
SheetSelectionChange
WindowActivate
Occurs when any workbook window is activated.
WindowDeactivate
Occurs when any workbook window is deactivated.
WindowResize
Occurs when any workbook window is resized.
WorkbookActivate
Occurs when any workbook is activated.
WorkbookAddinInstall
Occurs when a workbook is installed as an add-in.
WorkbookAddinUninstall
Occurs when any add-in workbook is uninstalled.
Occurs immediately before any open workbook
closes.
WorkbookBeforeClose
WorkbookBeforePrint
Occurs before any open workbook is printed.
WorkbookBeforeSave
Occurs before any open workbook is saved.
WorkbookDeactivate
Occurs when any open workbook is deactivated.
Occurs when a new sheet is created in any open
workbook.
WorkbookNewSheet
WorkbookOpen
Occurs when a workbook is opened.
WorkbookPivotTableCloseConnection
(Excel 10 only)
Occurs after a PivotTable report connection has
been closed.
WorkbookPivotTableOpenConnection (Excel
10 only)
Occurs after a PivotTable report connection has
been opened.
Unfortunately, Excel makes it a bit more difficult to reach the Application events than events in
the other categories. Here is a step-by-step procedure for reaching the event code shells for the
Application events:
1.
Use the VBA Insert menu to insert a class module into your project. Let us call this class
module CApp (short for Class Application ). In the declaration section of the class
module, add the line:
Public WithEvents App As Application
Choosing the App object in the objects drop-down should now give you access to the
Application event code shells, as shown in Figure 11-2 .
Figure 11-2. Application-level events
2.
In the code module in which you want to activate Application-level events (say, the code
module associated with a workbook, worksheet, or chart), place the following declaration
in the declarations section of the module:
 
Search JabSto ::




Custom Search