Application Level
There are 57 different events.
More details on how to add these events can be found here: VBA > Events > Application Level
Switching focus between applications does not trigger activation or deactivation of any of the Application, Workbook, Worksheet or Windows events.
| Event | Description |
| AfterCalculate | Occurs when all synchronous and asynchronous refresh activity and all calculation processes have completed. |
| NewWorkbook Cast (AppEvents_Event) | Occurs when a new workbook is created. This event is not raised when a new workbook is created from a template or an existing workbook. |
| ProtectedViewWindowActivate | Occurs when a protected view is activated. |
| ProtectedViewWindowBeforeClose | Occurs before a protected view window or workbook closes. |
| ProtectedViewWindowBeforeEdit | Occurs before editing is enabled on the workbook or window. |
| ProtectedViewWindowDeactivate | Occurs when a protected view is deactivated. |
| ProtectedViewWindowOpen | Occurs when a workbook is opened in a protected view window. |
| ProtectedViewWindowResize | Occurs when any protected view window is resized. |
| SheetActivate | Occurs when any worksheet (worksheet or chart sheet) in any open workbook is selected. This should be used instead of the OnSheetActivate property. The activated sheet is passed as an object which can be cast either to a worksheet or chart. |
| SheetBeforeDelete | Occurs before any sheet is deleted. |
| SheetBeforeDoubleClick | Occurs before any cell in any worksheet in any workbook is double clicked. This does not include Chart sheets. This should be used instead of the OnDoubleClick property. This occurs before the default double click. The activated sheet is passed as an object although this object can only be a worksheet (never a chart). |
| SheetBeforeRightClick | Occurs before the user right clicks on any worksheet in any open workbook. This does not include Chart sheets. The activated sheet is passed as an object although this object can only be a worksheet (never a chart). |
| SheetCalculate | Occurs after the user recalculates any worksheet in any workbook. This does not include Chart sheets. This should be used instead of the OnCalculate property. The activated sheet is passed as an object although this object can only be a worksheet (never a chart). |
| SheetChange | Occurs when the user changes a cell formula in any worksheet in any open workbook. This does not include Chart sheets. This should be used instead of the OnEntry property. The activated sheet is passed as an object although this object can only be a worksheet (never a chart). |
| SheetDeactivate | Occurs when the user deactivates any worksheet in any open workbook. This should be used instead of the OnSheetDeactivate property. The activated sheet is passed as an object although this object can only be a worksheet (never a chart). |
| SheetFollowHyperlink | Occurs when you click any hyperlink in a workbook. |
| SheetLensGalleryRenderComplete | Occurs after a callout gallery's icons have finished rendering (dynamic and static). |
| SheetPivotTableAfterValueChange | Occurs after a cell or range of cells inside a pivot table are edited or recalculated (for cells that contain formulas). |
| SheetPivotTableBeforeAllocateChanges | Occurs before changes are applied to a pivot table. |
| SheetPivotTableBeforeCommitChanges | Occurs before changes are committed against the OLAP data source for a pivot table. |
| SheetPivotTableBeforeDiscardChanges | Occurs before changes to a pivot table are discarded. |
| SheetPivotTableUpdate | Occurs after the sheet of a pivot table report has been updated. |
| SheetSelectionChange | Occurs when the user changes the current selection on any worksheet in any open workbook. The activated sheet is passed as an object although this object can only be a worksheet. This event is not raised on chart sheets. |
| SheetTableUpdate | Occurs when a table on a worksheet is updated. |
| WindowActivate | Occurs when the user moves focus to another window in any open workbook. This should be used instead of the OnWindow property. |
| WindowDeactivate | Occurs when the user moves focus away from an open window in any open workbook. This should be used instead of the OnWindow property. |
| WindowResize | Occurs when the user resizes or minimises any window in any open workbook. Only fired if the workbook window is not maximised. Does not fire when you resize or minimise the outer application window. |
| WorkbookActivate | Occurs when the user moves focus to another open workbook. |
| WorkbookAddinInstall | Occurs when the user installs a workbook as an add-in. |
| WorkbookAddinUninstall | Occurs when the user uninstalls a workbook as an add-in. |
| WorkbookAfterRemoteChange | Occurs after a remote user's edits to the workbook are merged. |
| WorkbookAfterSave | Occurs after the workbook is saved. |
| WorkbookAfterXmlExport | Occurs after Excel saves or exports data from a workbook to an XML data file. |
| WorkbookAfterXmlImport | Occurs after an existing XML data connection is refreshed or after new XML data is imported into the workbook. |
| WorkbookBeforeClose | Occurs before any open workbook is closed. This gives you a chance to prevent the closing of a workbook. If the event handler sets the cancel to true, the pending close is cancelled and the workbook remains open. Cannot be used to determine if a workbook is actually going to be closed because this event is fired before the user is prompted to save any changes and they could press Cancel. This event is fired after the Workbook.BeforeClose event. |
| WorkbookBeforePrint | Occurs before any open workbook is printed. |
| WorkbookBeforeRemoteChange | Occurs before a remote user's edits to the workbook are merged. |
| WorkbookBeforeSave | Occurs before any open workbook is saved. |
| WorkbookBeforeXmlExport | Occurs before Excel saves or exports data from a workbook to an XML data file. |
| WorkbookBeforeXmlImport | Occurs before an existing XML data connection is refreshed or after new XML data is imported into the workbook. |
| WorkbookDeactivate | Occurs when the user moves the focus away from any open workbook. |
| WorkbookModelChange | Occurs when the data model is updated. |
| WorkbookNewChart | Occurs when a new chart is created in any open workbook. |
| WorkbookNewSheet | Occurs when the user adds a new worksheet to any open workbook. |
| WorkbookOpen | Occurs when the user opens any workbook. This event is raised when a new workbook is created from a template or an existing workbook. |
| WorkbookPivotTableCloseConnection | Occurs when a pivot table closes its connection to its database. |
| WorkbookPivotTableOpenConnection | Occurs when a pivot table opens its connection to its database. |
| WorkbookRowsetComplete | Occurs when a user drills through a recordset or invokes the rowset action on a pivot table object. |
| WorkbookSync | Redundant. Occurs when a workbook that is part of a document workspace is synchronized with a copy on the server. |
AfterCalculate
Private Sub Application_AfterCalculate()
End Sub
NewWorkbook
Private Sub Application_NewWorkbook( _
ByVal Wb As Workbook)
End Sub
public void AppEvents_NewWorkbook(Excel.Workbook Wb)
{
WbkEvents = (Excel.Workbook)gApplicationExcel.ActiveWorkbook;
if (mbFireEvents == true)
AppEventsNewWorkbook_Event?.Invoke();
}
Public Sub AppEvents_NewWorkbook(ByVal Wb As Excel.Workbook) _
Handles AppEvents2.NewWorkbook
WbkEvents = CType(gApplicationExcel.ActiveWorkbook, Excel.Workbook)
If (mbFireEvents = True) Then
RaiseEvent AppEventsNewWorkbook_Event()
End If
End Sub
ProtectedViewWindowActivate
Private Sub Application_ProtectedViewWindowActivate( _
ByVal Pvw As ProtectedViewWindow)
End Sub
ProtectedViewWindowBeforeClose
Private Sub Application_ProtectedViewWindowBeforeClose( _
ByVal Pvw As ProtectedViewWindow, _
ByVal Reason As XlProtectedViewCloseReason,
ByRef Cancel As Boolean)
End Sub
ProtectedViewWindowBeforeEdit
Private Sub Application_ProtectedViewWindowBeforeEdit( _
ByVal Pvw As ProtectedViewWindow, _
ByRef Cancel As Boolean)
End Sub
ProtectedViewWindowDeactivate
Private Sub Application_ProtectedViewWindowDeactivate( _
ByVal Pvw As ProtectedViewWindow)
End Sub
ProtectedViewWindowOpen
Private Sub Application_ProtectedViewWindowOpen( _
ByVal Pvw As ProtectedViewWindow)
End Sub
ProtectedViewWindowResize
Private Sub Application_ProtectedViewWindowResize( _
ByVal Pvw As ProtectedViewWindow)
End Sub
SheetActivate
Private Sub Application_SheetActivate( _
ByVal Sh As Object)
End Sub
SheetBeforeDelete
Private Sub Application_SheetBeforeDelete( _
ByVal Sh As Object)
End Sub
SheetBeforeDoubleClick
Private Sub Application_SheetBeforeDoubleClick( _
ByVal Sh As Object, _
ByVal Target As Range, _
ByRef Cancel As Boolean)
End Sub
SheetBeforeRightClick
Private Sub Application_SheetBeforeRightClick( _
ByVal Sh As Object, _
ByVal Target As Range, _
ByRef Cancel As Boolean)
End Sub
public void AppEvents_SheetBeforeRightClick(object Sh, Excel.Range Target, ref bool Cancel)
{
if (mbFireEvents == true)
AppEventsSheetBeforeRightClick_Event?.Invoke(Sh, Target, Cancel);
}
Public Sub AppEvents_SheetBeforeRightClick(ByVal Sh As Object, _
ByVal Target As Excel.Range, _
ByRef Cancel As Boolean) _
Handles AppEvents.SheetBeforeRightClick
If (mbFireEvents = True) Then
RaiseEvent AppEventsSheetBeforeRightClick_Event(Sh, Target, Cancel)
End If
End Sub
SheetCalculate
Private Sub Application_SheetCalculate( _
ByVal Sh As Object)
End Sub
SheetChange
Private Sub Application_SheetChange( _
ByVal Sh As Object, _
ByVal Target As Range)
End Sub
SheetDeactivate
Private Sub Application_SheetDeactivate( _
ByVal Sh As Object)
End Sub
public void AppEvents_SheetDeactivate(object Sh)
{
if (mbFireEvents == true)
AppEventsSheetDeactivate_Event?.Invoke(Sh);
}
Public Sub AppEvents_SheetDeactivate(ByVal Sh As Object) _
Handles AppEvents.SheetDeactivate
If (mbFireEvents = True) Then
RaiseEvent AppEventsSheetDeactivate_Event(Sh)
End If
End Sub
SheetFollowHyperlink
Private Sub Application_SheetFollowHyperlink( _
ByVal Sh As Object, _
ByVal Target As Hyperlink)
End Sub
SheetLensGalleryRenderComplete
Private Sub Application_SheetLensGalleryRenderComplete( _
ByVal Sh As Object)
End Sub
SheetPivotTableAfterValueChange
Private Sub Application_SheetPivotTableAfterValueChange( _
ByVal Sh As Object, _
ByVal TargetPivotTable As PivotTable, _
ByVal TargetRange As Range)
End Sub
SheetPivotTableBeforeAllocateChanges
Private Sub Application_SheetPivotTableBeforeAllocateChanges( _
ByVal Sh As Object, _
ByVal TargetPivotTable As PivotTable, _
ByVal ValueChangeStart As Long, _
ByVal ValueChangeEnd As Long, _
ByRef Cancel As Boolean)
End Sub
SheetPivotTableBeforeCommitChanges
Private Sub Application_SheetPivotTableBeforeCommitChanges( _
ByVal Sh As Object, _
ByVal TargetPivotTable As PivotTable, _
ByVal ValueChangeStart As Long, _
ByVal ValueChangeEnd As Long, _
ByRef Cancel As Boolean)
End Sub
SheetPivotTableBeforeDiscardChanges
Private Sub Application_SheetPivotTableBeforeDiscardChanges( _
ByVal Sh As Object, _
ByVal TargetPivotTable As PivotTable, _
ByVal ValueChangeStart As Long, _
ByVal ValueChangeEnd As Long)
End Sub
SheetPivotTableUpdate
Private Sub Application_SheetPivotTableUpdate( _
ByVal Sh As Object, _
ByVal Target As PivotTable)
End Sub
SheetSelectionChange
Private Sub Application_SheetSelectionChange( _
ByVal Sh As Object, _
ByVal Target As Range)
End Sub
SheetTableUpdate
Private Sub Application_SheetTableUpdate( _
ByVal Sh As Object, _
ByVal Target As TableObject)
End Sub
WindowActivate
Private Sub Application_WindowActivate( _
ByVal Wb As Workbook, _
ByVal Wn As Window)
End Sub
WindowDeactivate
Private Sub Application_WindowDeactivate( _
ByVal Wb As Workbook, _
ByVal Wn As Window)
End Sub
public void AppEvents_WindowDeactivate(Excel.Workbook Wb, Excel.Window Wn)
{
if (mbFireEvents == true)
AppEventsWindowDeactivate_Event?.Invoke(Wb, Wn);
}
Public Sub AppEvents_WindowDeactivate(ByVal Wb As Excel.Workbook, _
ByVal Wn As Excel.Window) _
Handles AppEvents.WindowDeactivate
If (mbFireEvents = True) Then
RaiseEvent AppEventsWindowDeactivate_Event(Wb, Wn)
End If
End Sub
WindowResize
Private Sub Application_WindowResize( _
ByVal Wb As Workbook, _
ByVal Wn As Window)
End Sub
public void AppEvents_WindowResize(Excel.Workbook Wb, Excel.Window Wn)
{
if (mbFireEvents == true)
AppEventsWindowResize_Event?.Invoke(Wb, Wn);
}
Public Sub AppEvents_WindowResize(ByVal Wb As Excel.Workbook, _
ByVal Wn As Excel.Window) _
Handles AppEvents.WindowResize
If (mbFireEvents = True) Then
RaiseEvent AppEventsWindowResize_Event(Wb, Wn)
End If
End Sub
WorkbookActivate
Private Sub Application_WorkbookActivate( _
ByVal Wb As Workbook)
End Sub
WorkbookAddinInstall
Private Sub Application_WorkbookAddinInstall( _
ByVal Wb As Workbook)
End Sub
public void AppEvents_WorkbookAddinInstall(Excel.Workbook Wb)
{
if (mbFireEvents == true)
AppEventsWorkbookAddinInstall_Event?.Invoke(Wb);
}
Public Sub AppEvents_WorkbookAddinInstall(ByVal Wb As Excel.Workbook) _
Handles AppEvents.WorkbookAddinInstall
If (mbFireEvents = True) Then
RaiseEvent AppEventsWorkbookAddinInstall_Event(Wb)
End If
End Sub
WorkbookAddinUninstall
Private Sub Application_WorkbookAddinUninstall( _
ByVal Wb As Workbook)
End Sub
public void AppEvents_WorkbookAddinUninstall(Excel.Workbook Wb)
{
if (mbFireEvents == true)
AppEventsWorkbookAddinUninstall_Event?.Invoke(Wb);
}
Public Sub AppEvents_WorkbookAddinUninstall(ByVal Wb As Excel.Workbook) _
Handles AppEvents.WorkbookAddinUninstall
If (mbFireEvents = True) Then
RaiseEvent AppEventsWorkbookAddinUninstall_Event(Wb)
End If
End Sub
WorkbookAfterRemoteChange
Private Sub Application_WorkbookAfterRemoteChange()
End Sub
WorkbookAfterSave
Private Sub Application_WorkbookAfterSave( _
ByVal Wb As Workbook, _
ByVal Success As Boolean)
End Sub
WorkbookAfterXmlExport
Private Sub Application_WorkbookAfterXmlExport( _
ByVal Wb As Workbook, _
ByVal Map As XmlMap, _
ByVal Url As String, _
ByVal Result As XlXmlExportResult)
End Sub
WorkbookAfterXmlImport
Private Sub Application_WorkbookAfterXmlImport( _
ByVal Wb As Workbook, _
ByVal Map As XmlMap, _
ByVal IsRefresh As Boolean, _
ByVal Result As XlXmlImportResult)
End Sub
WorkbookBeforeClose
Private Sub Application_WorkbookBeforeClose( _
ByVal Wb As Workbook, _
ByRef Cancel As Boolean)
End Sub
public void AppEvents_WorkbookBeforeClose(Excel.Workbook Wb, ref bool Cancel)
{
if (mbFireEvents == true)
AppEventsWorkbookBeforeClose_Event?.Invoke(Wb, Cancel);
}
Public Sub AppEvents_WorkbookBeforeClose(ByVal Wb As Excel.Workbook, _
ByRef Cancel As Boolean) _
Handles AppEvents.WorkbookBeforeClose
If (mbFireEvents = True) Then
RaiseEvent AppEventsWorkbookBeforeClose_Event(Wb, Cancel)
End If
End Sub
WorkbookBeforePrint
Private Sub Application_WorkbookBeforePrint( _
ByVal Wb As Workbook, _
ByRef Cancel As Boolean)
End Sub
public void AppEvents_WorkbookBeforePrint(Excel.Workbook Wb, ref bool Cancel)
{
if (mbFireEvents == true)
AppEventsWorkbookBeforePrint_Event?.Invoke(Wb, Cancel);
}
Public Sub AppEvents_WorkbookBeforePrint(ByVal Wb As Excel.Workbook, _
ByRef Cancel As Boolean) _
Handles AppEvents.WorkbookBeforePrint
If (mbFireEvents = True) Then
RaiseEvent AppEventsWorkbookBeforePrint_Event(Wb, Cancel)
End If
End Sub
WorkbookBeforeRemoteChange
Private Sub Application_WorkbookBeforeRemoteChange()
End Sub
WorkbookBeforeSave
Private Sub Application_WorkbookBeforeSave( _
ByVal Wb As Workbook, _
ByVal SaveAsUI As Boolean, _
ByRef Cancel As Boolean)
End Sub
public void AppEvents_WorkbookBeforeSave(Excel.Workbook Wb, bool SaveAsUI, ref bool Cancel)
{
if (mbFireEvents == true)
AppEventsWorkbookBeforeSave_Event?.Invoke(Wb, SaveAsUI, Cancel);
}
Public Sub AppEvents_WorkbookBeforeSave(ByVal Wb As Excel.Workbook, _
ByVal SaveAsUI As Boolean, _
ByRef Cancel As Boolean) _
Handles AppEvents.WorkbookBeforeSave
If (mbFireEvents = True) Then
RaiseEvent AppEventsWorkbookBeforeSave_Event(Wb, SaveAsUI, Cancel)
End If
End Sub
Private Sub Application_WorkbookBeforeXmlExport( _
ByVal Wb As Workbook, _
ByVal Map As XmlMap, _
ByVal Url As String, _
ByRef Cancel As Boolean)
End Sub
Private Sub Application_WorkbookBeforeXmlImport( _
ByVal Wb As Workbook, _
ByVal Map As XmlMap, _
ByVal Url As String, _
ByVal IsRefresh As Boolean, _
ByRef Cancel As Boolean)
End Sub
WorkbookDeactivate
Private Sub Application_WorkbookDeactivate( _
ByVal Wb As Workbook)
End Sub
public void AppEvents_WorkbookDeactivate(Excel.Workbook Wb)
{
if (mbFireEvents == true)
AppEventsWorkbookDeactivate_Event?.Invoke(Wb);
}
Public Sub AppEvents_WorkbookDeactivate(ByVal Wb As Excel.Workbook) _
Handles AppEvents.WorkbookDeactivate
If (mbFireEvents = True) Then
RaiseEvent AppEventsWorkbookDeactivate_Event(Wb)
End If
End Sub
WorkbookModelChange
Private Sub Application_WorkbookModelChange( _
ByVal Wb As Workbook, _
ByVal Changes As ModelChanges)
End Sub
WorkbookNewChart
Private Sub Application_WorkbookNewChart( _
ByVal Wb As Workbook, _
ByVal Ch As Chart)
End Sub
WorkbookNewSheet
Private Sub Application_WorkbookNewSheet( _
ByVal Wb As Workbook, _
ByVal Sh As Object)
End Sub
public void AppEvents_WorkbookNewSheet(Excel.Workbook Wb, object Sh)
{
// chart sheets ??
WshEvents = (Excel.Worksheet)gApplicationExcel.ActiveSheet;
if (mbFireEvents == true)
AppEventsWorkbookNewSheet_Event?.Invoke(Wb, Sh);
}
Public Sub AppEvents_WorkbookNewSheet(ByVal Wb As Excel.Workbook, _
ByVal Sh As Object) _
Handles AppEvents.WorkbookNewSheet
'chart sheets ??
WshEvents = CType(gApplicationExcel.ActiveSheet, Excel.Worksheet)
If (mbFireEvents = True) Then
RaiseEvent AppEventsWorkbookNewSheet_Event(Wb, Sh)
End If
End Sub
WorkbookOpen
Private Sub Application_WorkbookOpen( _
ByVal Wb As Workbook)
End Sub
public void AppEvents_WorkbookOpen(Excel.Workbook Wb)
{
WbkEvents = (Excel.Workbook)gApplicationExcel.ActiveWorkbook;
// chart sheets ??
WshEvents = (Excel.Worksheet)gApplicationExcel.ActiveSheet;
if (mbFireEvents == true)
AppEventsWorkbookOpen_Event?.Invoke(Wb);
}
Public Sub AppEvents_WorkbookOpen(ByVal Wb As Excel.Workbook) _
Handles AppEvents.WorkbookOpen
WbkEvents = CType(gApplicationExcel.ActiveWorkbook, Excel.Workbook)
'chart sheets ??
WshEvents = CType(gApplicationExcel.ActiveSheet, Excel.Worksheet)
If (mbFireEvents = True) Then
RaiseEvent AppEventsWorkbookOpen_Event(Wb)
End If
End Sub
WorkbookPivotTableCloseConnection
Private Sub Application_WorkbookPivotTableCloseConnection( _
ByVal Wb As Workbook, _
ByVal Target As PivotTable)
End Sub
public void AppEvents_WorkbookPivotTableCloseConnection(Excel.Workbook Wb, Excel.PivotTable Target)
{
if (mbFireEvents == true)
AppEventsWorkbookPivotTableCloseConnection_Event?.Invoke(Wb, Target);
}
Public Sub AppEvents_WorkbookPivotTableCloseConnection(ByVal Wb As Excel.Workbook, _
ByVal Target As Excel.PivotTable) _
Handles AppEvents.WorkbookPivotTableCloseConnection
If (mbFireEvents = True) Then
RaiseEvent AppEventsWorkbookPivotTableCloseConnection_Event(Wb, Target)
End If
End Sub
WorkbookPivotTableOpenConnection
Private Sub Application_WorkbookPivotTableOpenConnection( _
ByVal Wb As Workbook, _
ByVal Target As PivotTable)
End Sub
public void AppEvents_WorkbookPivotTableOpenConnection(Excel.Workbook Wb, Excel.PivotTable Target)
{
if (mbFireEvents == true)
AppEventsWorkbookPivotTableOpenConnection_Event?.Invoke(Wb, Target);
}
Public Sub AppEvents_WorkbookPivotTableOpenConnection(ByVal Wb As Excel.Workbook, _
ByVal Target As Excel.PivotTable) _
Handles AppEvents.WorkbookPivotTableOpenConnection
If (mbFireEvents = True) Then
RaiseEvent AppEventsWorkbookPivotTableOpenConnection_Event(Wb, Target)
End If
End Sub
WorkbookRowsetComplete
Private Sub Application_WorkbookRowsetComplete( _
ByVal Wb As Workbook, _
ByVal Description As String, _
ByVal Sheet As String, _
ByVal Success As Boolean)
End Sub
Application_WorkbookSync
Private Sub Application_WorkbookSync( _
ByVal Wb As Workbook, _
ByVal SyncEventType As Office.MsoSyncEventType)
End Sub
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext