Application Level

EventDescription36516131007
AfterCalculateOccurs when all synchronous and asynchronous refresh activity and all calculation processes have completed.YYYYY
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.YYYYY
ProtectedViewWindowActivateOccurs when a protected view is activated.YYYY 
ProtectedViewWindowBeforeCloseOccurs before a protected view window or workbook closes.YYYY 
ProtectedViewWindowBeforeEditOccurs before editing is enabled on the workbook or windowYYYY 
ProtectedViewWindowDeactivateOccurs when a protected view is deactivatedYYYY 
ProtectedViewWindowOpenOccurs when a workbook is opened in a protected view windowYYYY 
ProtectedViewWindowResizeOccurs when any protected view window is resized.YYYY 
SheetActivateOccurs when any worksheet 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.
YYYYY
SheetBeforeDelete YYY  
SheetBeforeDoubleClickOccurs 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)
YYYYY
SheetBeforeRightClickOccurs 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)
YYYYY
SheetCalculateOccurs 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)
YYYYY
SheetChangeOccurs 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)
YYYYY
SheetDeactivateOccurs 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)
YYYYY
SheetFollowHyperlinkOccurs when you click any hyperlnk in a workbook.YYYYY
SheetLensGalleryRenderCompleteOccurs after a callout gallery's icons have finished rendering (dynamic and static)YYY  
SheetPivotTableAfterValueChangeOccurs after a cell or range of cells inside a pivottable are edited or recalculated (for cells that contain formulas)YYYY 
SheetPivotTableBeforeAllocateChangesOccurs before changes are applied to a pivottable.YYYY 
SheetPivotTableBeforeCommitChangesOccurs before changes are committed against the OLAP data source for a pivottable.YYYY 
SheetPivotTableBeforeDiscardChangesOccurs before changes to a pivottable are discardedYYYY 
SheetPivotTableUpdateOccurs after the sheet of a pivottable report has been updated.YYYYY
SheetSelectionChangeOccurs 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
YYYYY
SheetTableUpdate Y    
WindowActivateOccurs when the user moves focus to another window in any open workbook. This should be used instead of the OnWindow property.YYYYY
WindowDeactivateOccurs when the user moves focus away from an open window in any open workbook. This should be used instead of the OnWindow property.YYYYY
WindowResizeOccurs 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.
YYYYY
WorkbookActivateOccurs when the user moves focus to another open workbook.YYYYY
WorkbookAddinInstallOccurs when the user installs a workbook as an addin.YYYYY
WorkbookAddinUninstallOccurs when the user uninstalls a workbook as an addin.YYYYY
WorkbookAfterXmlExportOccurs after Excel saves or exports data from a workbook to an XML data file.YYYYY
WorkbookAfterXmlImportOccurs after an existing XML data connection is refreshed or after new XML data is imported into the workbook.YYYYY
WorkbookBeforeCloseOccurs 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. If the user is prompted to save this happens before (of after) this event ?
YYYYY
WorkbookBeforePrintOccurs before any open workbook is printed.YYYYY
WorkbookBeforeSaveOccurs before any open workbook is saved.YYYYY
WorkbookBeforeXmlExportOccurs before Excel saves or exports data from a workbook to an XML data file.YYYYY
WorkbookBeforeXmlImportOccurs before an existing XML data connection is refreshed or after new XML data is imported into the workbook.YYYYY
WorkbookDeactivateOccurs when the user moves the focus away from any open workbook.YYYYY
WorkbookModelChange YYY  
WorkbookNewChartOccurs when a new chart is created in any open workbook.YYYY 
WorkbookNewSheetOccurs when the user adds a new worksheet to any open workbook.YYYYY
WorkbookOpenOccurs when the user opens any workbook.
This event is raised when a new workbook is created from a template or an existing workbook.
YYYYY
WorkbookPivotTableCloseConnectionOccurs when a pivottable closes its connection to its database.YYYYY
WorkbookPivotTableOpenConnectionOccurs when a pivottable opens its connection to its database.YYYYY
WorkbookRowsetCompleteOccurs when a user drills through a recordset or invokes the rowset action on a pivottable object.YYYYY
WorkbookSyncRedundant Occurs when a workbook that is part of a document workspace is synchronized with a copy on the server.YYYYY


Activate and Deactivate

Switching focus between applications does not trigger activation or deactivation of any of the Application, Workbook, Worksheet or Windows events


Worksheet or Chart

void WhichObject (string eventName, object sheet) 
{
   Excel.Worksheet wsh = sheet as Excel.Worksheet
   if (worksheet != null)
   {
      // this is a worksheet
   }
   Excel.Chart cht = sheet as Excel.Chart
   {
      // this is a chart
   }
}


In VSTO you do not have to keep a reference to the workbook, worksheet or chart objects when handling events because they are already being kept by the project items generated by the project.
However you do need to keep a reference to the Application object
To get a worksheet or chart we can use the VSTO's Global object


Example

Private Sub Application_NewWorkbook(ByVal Wb As Workbook) 
End Sub

Private Sub Application_SheetActivate(ByVal Sh As Object)
   If TypeName(Sh) = "Worksheet" Then
   End If
   If TypeName(Sh) = "Chart Sheet" Then
   End If
End Sub

Private Sub Application_SheetBeforeDoubleClick(ByVal Sh As Object, _
                                               ByVal Target As Range, _
                                               Cancel As Boolean)
End Sub

Private Sub Application_SheetBeforeRightClick(ByVal Sh As Object, _
                                              ByVal Target As Range, _
                                              Cancel As Boolean)
End Sub

Private Sub Application_SheetCalculate(ByVal Sh As Object)
End Sub

Private Sub Application_SheetChange(ByVal Sh As Object, _
                                    ByVal Target As Range)
End Sub

Private Sub Application_SheetDeactivate(ByVal Sh As Object)
End Sub

Private Sub Application_SheetFollowHyperlink(ByVal Sh As Object, _
                                             ByVal Target As Hyperlink)
End Sub

Private Sub Application_SheetPivotTableUpdate(ByVal Sh As Object, _
                                              ByVal Target As PivotTable)
End Sub

Private Sub Application_SheetSelectionChange(ByVal Sh As Object, _
                                             ByVal Target As Range)
End Sub

Private Sub Application_WindowActivate(ByVal Wb As Workbook, _
                                       ByVal Wn As Window)
End Sub

Private Sub Application_WindowDeactivate(ByVal Wb As Workbook, _
                                         ByVal Wn As Window)
End Sub

Private Sub Application_WindowResize(ByVal Wb As Workbook, _
                                     ByVal Wn As Window)
End Sub

Private Sub Application_WorkbookActivate(ByVal Wb As Workbook)
End Sub

Private Sub Application_WorkbookAddinInstall(ByVal Wb As Workbook)
End Sub

Private Sub Application_WorkbookAddinUninstall(ByVal Wb As Workbook)
End Sub

Private Sub Application_WorkbookAfterXmlExport(ByVal Wb As Workbook, _
                                               ByVal Map As XmlMap, _
                                               ByVal Url As String, _
                                               ByVal Result As XlXmlExportResult)
End Sub

Private Sub Application_WorkbookAfterXmlImport(ByVal Wb As Workbook, _
                                               ByVal Map As XmlMap, _
                                               ByVal IsRefresh As Boolean, _
                                               ByVal Result As XlXmlImportResult)
End Sub

Private Sub Application_WorkbookBeforeClose(ByVal Wb As Workbook, _
                                            Cancel As Boolean)
'setting the Cancel argument to will prevent the workbook from being closed
   Cancel = True
End Sub

Private Sub Application_WorkbookBeforePrint(ByVal Wb As Workbook, _
                                            Cancel As Boolean)
End Sub

Private Sub Application_WorkbookBeforeSave(ByVal Wb As Workbook, _
                                           ByVal SaveAsUI As Boolean, _
                                           Cancel As Boolean)
End Sub

Private Sub Application_WorkbookBeforeXmlExport(ByVal Wb As Workbook, _
                                                ByVal Map As XmlMap, _
                                                ByVal Url As String, _
                                                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, _
                                                Cancel As Boolean)
End Sub

Private Sub Application_WorkbookDeactivate(ByVal Wb As Workbook)
End Sub

Private Sub Application_WorkbookNewSheet(ByVal Wb As Workbook, _
                                         ByVal Sh As Object)
End Sub

Private Sub Application_WorkbookOpen(ByVal Wb As Workbook)
End Sub

Private Sub Application_WorkbookPivotTableCloseConnection(ByVal Wb As Workbook, _
                                                          ByVal Target As PivotTable)
End Sub

Private Sub Application_WorkbookPivotTableOpenConnection(ByVal Wb As Workbook, _
                                                         ByVal Target As PivotTable)
End Sub

Private Sub Application_WorkbookSync(ByVal Wb As Workbook, _
                                     ByVal SyncEventType As Office.MsoSyncEventType)
End Sub

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

PrevNext