Workbook Level
There are 40 different events.
More details on how to add these events can be found here: VBA > Events > Workbook Level
Event | Description | 365 | 21 | 16 | 13 | 10 | 07 |
Activate (VBA) Cast (WorkbookEvents_Event) | Redundant. Occurs when the focus is moved to this workbook. | Y | Y | Y | Y | Y | Y |
AddinInstall | Occurs when the workbook is installed as an addin. This event is only fired when an add-in is manually added to the "Add-ins" dialog box and not when Excel opens. This should be used instead of the Auto_Add macro. | Y | Y | Y | Y | Y | Y |
AddinUninstall | Occurs when the workbook is uninstalled as an addin. This event is only fired when an add-in is manually removed from the "Add-ins" dialog box and not when Excel is closed. This should be used instead of the Auto_Remove macro. | Y | Y | Y | Y | Y | Y |
AfterRemoteChange | Occurs after a remote user's edits to the workbook are merged. | Y | Y | ||||
AfterSave | Occurs when the workbook is saved. | Y | Y | Y | Y | ||
AfterXMLExport | Occurs after data is exported to an XML data file. | Y | Y | Y | Y | Y | Y |
AfterXMLImport | Occurs after data has been imported from an XML data file. | Y | Y | Y | Y | Y | Y |
BeforeClose | Occurs before the workbook is closed. This should be used instead of the Auto_Close macro. | Y | Y | Y | Y | Y | Y |
BeforePrint | Occurs before the workbook is printed. | Y | Y | Y | Y | Y | Y |
BeforeRemoteChange | Occurs before a remote user's edits to the workbook are merged. | Y | Y | ||||
BeforeSave | Occurs before the workbook is saved. This should be used instead of the OnSave property. | Y | Y | Y | Y | Y | Y |
BeforeXMLExport | Occurs before data is exported to an XML list. | Y | Y | Y | Y | Y | Y |
BeforeXMLImport | Occurs before data is imported from an XML list. | Y | Y | Y | Y | Y | Y |
Deactivate | Occurs when focus is moved from this workbook to another workbook or window. | Y | Y | Y | Y | Y | Y |
ModelChange | Occurs when the data model is updated. | Y | Y | Y | Y | ||
NewChart | Occurs when a new chart is created in the workbook. | Y | Y | Y | Y | Y | |
NewSheet | Occurs before an additional worksheet is added to the workbook. | Y | Y | Y | Y | Y | Y |
Open | Occurs before the workbook is opened. This should be used instead of the Auto_Open macro. | Y | Y | Y | Y | Y | Y |
PivotTableCloseConnection | Occurs when a pivot table closes its connection to its datasource. | Y | Y | Y | Y | Y | Y |
PivotTableOpenConnection | Occurs when a pivot table opens its connection to its datasource. | Y | Y | Y | Y | Y | Y |
RowsetComplete | Occurs when a user either drills through a recordset or involves the rowset action on an OLAP pivot table. | Y | Y | Y | Y | Y | Y |
SheetActivate | Occurs when any worksheet in this workbook is selected. This should be used instead of the OnSheetActivate property. The activated sheet is passed an object which can be cast to either a worksheet or a chart sheet | Y | Y | Y | Y | Y | Y |
SheetBeforeDelete | Occurs when any sheet is deleted. | Y | Y | Y | Y | ||
SheetBeforeDoubleClick | Occurs before any cell is double clicked on any worksheet in this workbook. This should be used instead of the OnDoubleClick property. | Y | Y | Y | Y | Y | Y |
SheetBeforeRightClick | Occurs before any cell is right mouse clicked on any worksheet in this workbook. This does not include Chart sheets. | Y | Y | Y | Y | Y | Y |
SheetCalculate | Occurs after the user re-calculates any worksheet in this workbook. This should be used instead of the OnCalculate property. The activated sheet is passed an object which can be cast to either a worksheet or a chart sheet | Y | Y | Y | Y | Y | Y |
SheetChange | Occurs when any cell is changed either by the user or by an external link. This should be used instead of the OnEntry property. The activated sheet is passed an object although this is always a worksheet as this event is not raised for chart sheets | Y | Y | Y | Y | Y | Y |
SheetDeactivate | Occurs when a different worksheet is selected in this workbook. This should be used instead of the OnSheetDeactivate property. The activated sheet is passed an object although this is always a worksheet as this event is not raised for chart sheets | Y | Y | Y | Y | Y | Y |
SheetFollowHyperlink | Occurs when a hyperlink is clicked on a worksheet. | Y | Y | Y | Y | Y | Y |
SheetLensGalleryRenderComplete | Occurs when a callout gallery's icons (dynamic & static) have completed rendering for a worksheet. | Y | Y | Y | Y | ||
SheetPivotTableAfterValueChange | Occurs after a cell or range of cells inside a pivot table are edited or recalculated (for cells that contain formulas) | Y | Y | Y | Y | Y | |
SheetPivotTableBeforeAllocateChange | Occurs before changes are applied to a pivot table. | Y | Y | Y | Y | Y | |
SheetPivotTableBeforeCommitChanges | Occurs before changes are committed against the OLAP data source for a pivot table. | Y | Y | Y | Y | Y | |
SheetPivotTableBeforeDiscardChanges | Occurs before changes to a pivot table are discarded. | Y | Y | Y | Y | Y | |
SheetPivotTableChangeSync | Occurs after changes to a pivot table. | Y | Y | Y | Y | Y | |
SheetPivotTableUpdate | Occurs when a pivot table on a worksheet is updated. | Y | Y | Y | Y | Y | Y |
SheetSelectionChange | Occurs when the selection is changed on any worksheets in this workbook. This does not include Chart sheets. The activated sheet is passed an object although this is always a worksheet as this event is not raised for chart sheets. | Y | Y | Y | Y | Y | Y |
SheetTableUpdate | Occurs after the sheet table has been updated. | Y | Y | Y | Y | ||
Sync | Redundant. Occurs when a worksheet in a Document Workspace is synchronised with a copy of the worksheet on a server. | Y | Y | Y | Y | Y | Y |
WindowActivate | Occurs when focus is moved to any window that displays this workbook. This should be used instead of the OnWindow property. | Y | Y | Y | Y | Y | Y |
WindowDeactivate | Occurs when any window is de-selected. This should be used instead of the OnWindow property. | Y | Y | Y | Y | Y | Y |
WindowResize | Occurs when any window that displays this workbook is resized, opened, maximised or minimised. | Y | Y | Y | Y | Y | Y |
VBA Samples
Private Sub Workbook_Activate()
End Sub
Private Sub Workbook_AddinInstall()
End Sub
Private Sub Workbook_AddinUninstall()
End Sub
Private Sub Workbook_AfterRemoteChange()
End Sub
Private Sub Workbook_AfterSave( _
ByVal Success As Boolean)
End Sub
Private Sub Workbook_AfterXmlExport( _
ByVal Map As XmlMap, _
ByVal Url As String, _
ByVal Result As XlXmlExportResult)
End Sub
Private Sub Workbook_AfterXmlImport( _
ByVal Map As XmlMap, _
ByVal Url As String, _
ByVal Result As XlXmlExportResult)
End Sub
Private Sub Workbook_BeforeClose( _
ByRef Cancel As Boolean)
End Sub
Private Sub Workbook_BeforePrint( _
ByRef Cancel As Boolean)
End Sub
Private Sub Workbook_BeforeRemoteChange()
End Sub
Private Sub Workbook_BeforeSave( _
ByVal SaveAsUI As Boolean, _
ByRef Cancel As Boolean)
End Sub
Private Sub Workbook_BeforeXmlExport( _
ByVal Map As XmlMap, _
ByVal Url As String, _
ByRef Cancel As Boolean)
End Sub
Private Sub Workbook_BeforeXmlImport( _
ByVal Map As XmlMap, _
ByVal Url As String, _
ByVal IsRefresh As Boolean, _
ByRef Cancel As Boolean)
End Sub
Private Sub Workbook_Deactivate()
End Sub
Private Sub Workbook_ModelChange( _
ByVal Changes As ModelChanges)
End Sub
Private Sub Workbook_NewChart( _
ByVal Ch As Chart)
End Sub
Private Sub Workbook_NewSheet( _
ByVal Sh As Object)
End Sub
Private Sub Workbook_Open()
End Sub
Private Sub Workbook_PivotTableCloseConnection( _
ByVal Target As PivotTable)
End Sub
Private Sub Workbook_PivotTableOpenConnection( _
ByVal Target As PivotTable)
End Sub
Private Sub Workbook_RowsetComplete( _
ByVal Description As String, _
ByVal Sheet As String, _
ByVal Success As Boolean)
End Sub
Private Sub Workbook_SheetActivate( _
ByVal Sh As Object)
End Sub
Private Sub Workbook_SheetBeforeDelete( _
ByVal Sh As Object)
End Sub
Private Sub Workbook_SheetBeforeDoubleClick( _
ByVal Sh As Object, _
ByVal Target As Range, _
ByRef Cancel As Boolean)
End Sub
Private Sub Workbook_SheetBeforeRightClick( _
ByVal Sh As Object, _
ByVal Target As Range, _
ByRef Cancel As Boolean)
End Sub
Private Sub Workbook_SheetCalculate( _
ByVal Sh As Object)
End Sub
Private Sub Workbook_SheetChange( _
ByVal Sh As Object, _
ByVal Target As Range)
End Sub
Private Sub Workbook_SheetDeactivate( _
ByVal Sh As Object)
End Sub
Private Sub Workbook_SheetFollowHyperlink( _
ByVal Sh As Object, _
ByVal Target As Hyperlink)
End Sub
Private Sub Workbook_SheetLensGalleryRenderComplete( _
ByVal Sh As Object)
End Sub
Private Sub Workbook_SheetPivotTableAfterValueChange( _
ByVal Sh As Object, _
ByVal TargetPivotTable As PivotTable, _
ByVal TargetRange As Range)
End Sub
Private Sub Workbook_SheetPivotTableBeforeAllocateChanges( _
ByVal Sh As Object, _
ByVal TargetPivotTable As PivotTable, _
ByVal ValueChangeStart As Long, _
ByVal ValueChangeEnd As Long, _
ByRef Cancel As Boolean)
End Sub
Private Sub Workbook_SheetPivotTableBeforeCommitChanges( _
ByVal Sh As Object, _
ByVal TargetPivotTable As PivotTable, _
ByVal ValueChangeStart As Long, _
ByVal ValueChangeEnd As Long, _
ByRef Cancel As Boolean)
End Sub
Private Sub Workbook_SheetPivotTableBeforeDiscardChanges( _
ByVal Sh As Object, _
ByVal TargetPivotTable As PivotTable, _
ByVal ValueChangeStart As Long, _
ByVal ValueChangeEnd As Long)
End Sub
Private Sub Workbook_SheetPivotTableChangeSync( _
ByVal Sh As Object, _
ByVal Target As PivotTable)
End Sub
Private Sub Workbook_SheetPivotTableUpdate( _
ByVal Sh As Object, _
ByVal Target As PivotTable)
End Sub
Private Sub Workbook_SheetSelectionChange( _
ByVal Sh As Object, _
ByVal Target As Range)
End Sub
Private Sub Workbook_SheetTableUpdate( _
ByVal Sh As Object, _
ByVal Target As TableObject)
End Sub
Private Sub Workbook_Sync( _
ByVal SyncEventType As Office.MsoSyncEventType)
End Sub
Private Sub Workbook_WindowActivate( _
ByVal Wn As Window)
End Sub
Private Sub Workbook_WindowDeactivate( _
ByVal Wn As Window)
End Sub
Private Sub Workbook_WindowResize( _
ByVal Wn As Window)
End Sub
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext