Excel add-in on startup

☆樱花仙子☆ 提交于 2019-12-02 11:39:27

问题


I am creating an add in for Microsoft Excel using Visual C#. When I first created the solution, it included a function called ThisAddIn_Startup. I added the following code to this function:

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
    MessageBox.Show("Startup");
}

The message box does not show upon installing the add in and starting Microsoft Excel. Indeed, NOTHING in this function works when the add in loads. This is literally the only change I've made to this new project after first creating it. Why won't it work?


回答1:


Nothing is magic and ThisAddIn_Startup is called by something before executing your MessageBox.Show instruction.

You can use "Find All References" in Visual Studio, it will bring you to ThisAddin.InternalStartup(), a private method in ThisAddin.cs.

This method is called by the framework's runtime.

Did this explanation help?




回答2:


When developing AddIn's for Excel you will sometimes create bugs that will trigger Excel to disable the AddIn. If so you need to Go into Excel, go to File / Options and select Add-Ins. At the lower left of the screen there is a drop down list with the label "Manage:". Select "Disabled Items" and click Go button. If your tool is disabled you will see it there and you can re-enable it. This was an example from Office 2010. The new version might have rearranged this, I don't know.



来源:https://stackoverflow.com/questions/22608080/excel-add-in-on-startup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!