Private void OpenworkbookHandler(Excel.Workbook wb) += new Excel.AppEvents_WorkbookOpenEventHandler(OpenworkbookHandler) Note: all application level events must be declared globally withing ThisAddin.cs to maintain their lifetime.Įxcel/Application Events: C# code example WorkbookOpen event private void ThisAddIn_Startup(object sender, System.EventArgs e) The Excel events can be classified in two categories: As long as a handler adheres to this signature, the event source can invoke it when required. The event source publishes a defined event signature which all event handlers must adhere to. The event handler (or subscriber as some people call it) is the custom code (i.e., our code) that is invoked by the event source when the event happens. In the case of Excel, the event source is an instance of the Excel class that defines the event, such as a Workbook instance or a Worksheet instance. There are two broad parts of event handling: the event source and the event handler. The sinking and dispatching just happens automatically for us. When we trap these events from VBA we’re not really aware of the underlying mechanisms that enable Excel to callback into our code. They are defined in COM interfaces exported from Excel.exe.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |