Workbook Level

There are 40 different events.
More details on how to add these events can be found here: VBA > Events > Workbook Level

EventDescription3652116131007
Activate (VBA)
Cast (WorkbookEvents_Event)
Redundant. Occurs when the focus is moved to this workbook.YYYYYY
AddinInstallOccurs 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.
YYYYYY
AddinUninstallOccurs 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.
YYYYYY
AfterRemoteChangeOccurs after a remote user's edits to the workbook are merged.YY    
AfterSaveOccurs when the workbook is saved.YYYY  
AfterXMLExportOccurs after data is exported to an XML data file.YYYYYY
AfterXMLImportOccurs after data has been imported from an XML data file.YYYYYY
BeforeCloseOccurs before the workbook is closed. This should be used instead of the Auto_Close macro.YYYYYY
BeforePrintOccurs before the workbook is printed.YYYYYY
BeforeRemoteChangeOccurs before a remote user's edits to the workbook are merged.YY    
BeforeSaveOccurs before the workbook is saved. This should be used instead of the OnSave property.YYYYYY
BeforeXMLExportOccurs before data is exported to an XML list.YYYYYY
BeforeXMLImportOccurs before data is imported from an XML list.YYYYYY
DeactivateOccurs when focus is moved from this workbook to another workbook or window.YYYYYY
ModelChangeOccurs when the data model is updated.YYYY  
NewChartOccurs when a new chart is created in the workbook.YYYYY 
NewSheetOccurs before an additional worksheet is added to the workbook.YYYYYY
OpenOccurs before the workbook is opened. This should be used instead of the Auto_Open macro.YYYYYY
PivotTableCloseConnectionOccurs when a pivot table closes its connection to its datasource.YYYYYY
PivotTableOpenConnectionOccurs when a pivot table opens its connection to its datasource.YYYYYY
RowsetCompleteOccurs when a user either drills through a recordset or involves the rowset action on an OLAP pivot table.YYYYYY
SheetActivateOccurs 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
YYYYYY
SheetBeforeDeleteOccurs when any sheet is deleted.YYYY  
SheetBeforeDoubleClickOccurs before any cell is double clicked on any worksheet in this workbook. This should be used instead of the OnDoubleClick property.YYYYYY
SheetBeforeRightClickOccurs before any cell is right mouse clicked on any worksheet in this workbook. This does not include Chart sheets.YYYYYY
SheetCalculateOccurs 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
YYYYYY
SheetChangeOccurs 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
YYYYYY
SheetDeactivateOccurs 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
YYYYYY
SheetFollowHyperlinkOccurs when a hyperlink is clicked on a worksheet.YYYYYY
SheetLensGalleryRenderCompleteOccurs when a callout gallery's icons (dynamic & static) have completed rendering for a worksheet.YYYY  
SheetPivotTableAfterValueChangeOccurs after a cell or range of cells inside a pivot table are edited or recalculated (for cells that contain formulas)YYYYY 
SheetPivotTableBeforeAllocateChangeOccurs before changes are applied to a pivot table.YYYYY 
SheetPivotTableBeforeCommitChangesOccurs before changes are committed against the OLAP data source for a pivot table.YYYYY 
SheetPivotTableBeforeDiscardChangesOccurs before changes to a pivot table are discarded.YYYYY 
SheetPivotTableChangeSyncOccurs after changes to a pivot table.YYYYY 
SheetPivotTableUpdateOccurs when a pivot table on a worksheet is updated.YYYYYY
SheetSelectionChangeOccurs 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.YYYYYY
SheetTableUpdateOccurs after the sheet table has been updated.YYYY  
SyncRedundant. Occurs when a worksheet in a Document Workspace is synchronised with a copy of the worksheet on a server.YYYYYY
WindowActivateOccurs when focus is moved to any window that displays this workbook. This should be used instead of the OnWindow property.YYYYYY
WindowDeactivateOccurs when any window is de-selected. This should be used instead of the OnWindow property.YYYYYY
WindowResizeOccurs when any window that displays this workbook is resized, opened, maximised or minimised.YYYYYY

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