Workbook Level

There are 40 different events.

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


VBA Samples

Private Sub Workbook_Activate() 
End Sub

Private Sub Workbook_AddinInstall()
End Sub

Private Sub Workbook_AddinUninstall()
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_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

© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited

Top

PrevNext