c# using the event handler WorkbookOpen

后端 未结 1 1103
渐次进展
渐次进展 2021-01-16 10:18

I am programming an excel add-in and I want to execute certain code when a workbook is opened. This means that if they open excel and then open a workbook, the add-in will

相关标签:
1条回答
  • 2021-01-16 10:42

    Add this to InternalStartUp()

        this.Application.WorkbookOpen += new Excel.AppEvents_WorkbookOpenEventHandler(Application_WorkbookOpen);
    

    And then this function will be called when the workbook is opened

    void Application_WorkbookOpen(Excel.Workbook Wb)
    {
       //Do something         
    }
    

    Also, it is hidden in the #region VSTO generated code in ThisAddIn.cs by default.

    0 讨论(0)
提交回复
热议问题