开发者

c# using the event handler WorkbookOpen

开发者 https://www.devze.com 2023-03-30 18:01 出处:网络
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 execute the code.

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 execute the code.

I am assuming we have to 开发者_Go百科use the event handler: Application.WokbookOpen

But I do not know how to apply this.

Thank You!


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

精彩评论

暂无评论...
验证码 换一张
取 消