Excel加载项:Excel事件处理程序的新实例 [英] Excel Add-in: New Instance of Excel Event Handler

查看:136
本文介绍了Excel加载项:Excel事件处理程序的新实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部,

每当使用事件处理程序打开名为"Book1.xls"的新工作簿时,我都设计了一些代码来执行方法:
Excel.AppEvents_WorkbookOpenEventHandler(Application_WorkbookOpen)

创建新的excel实例时是否有类似的事件处理程序?

我有一种情况,我希望在以下两种情况下执行附加组件:1)用户按下按钮或2)用户从第3方程序中导出数据表,并且当该excel表打开时,该事件通过运行该方法来处理.我现在使用它与当前事件处理程序一起工作,但是我刚刚发现,当我从第3方程序中导出excel文件时,它会在新的excel实例中打开它,因此我的加载项不会看到"创建新的"Book1.xls".

All,

I have devised some code to execute a method whenever a new workbook named "Book1.xls" is opened using an event handler :

Excel.AppEvents_WorkbookOpenEventHandler(Application_WorkbookOpen)

Is there a similar event handler for when a new instance of excel is created?

I have a situation where I would like my add-on to be executed under two conditions: 1) the user presses a button OR 2) the user exports a data table from a 3rd party program, and when that excel table opens, that event is handled by running the method. I have it working now with the current event handler, but I just found out that when I export the excel file from the 3rd party program, it opens it up in a new instance of excel, so my add-on does not "see" the new "Book1.xls" created. Thanks in advance!

推荐答案

MS Excel应用程序可用事件列表,您可以在这里找到:^ ]

最有趣的事件是:
NewWorkbook-在创建新工作簿时发生. (继承自AppEvents_Event.)"首选
WorkbookBeforeXmlExport-在Microsoft Excel将数据从任何打开的工作簿保存或导出到XML数据文件之前发生. (继承自AppEvents_Event.)
WorkbookBeforeXmlImport-在刷新现有XML数据连接或将新XML数据导入任何打开的Microsoft Excel工作簿之前发生. (继承自AppEvents_Event.)
List of avalible events for MS Excel Application, you can find here: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.application_events.aspx[^]

The most interesting events are:
NewWorkbook - Occurs when a new workbook is created. (Inherited from AppEvents_Event.) ''prefered
WorkbookBeforeXmlExport - Occurs before Microsoft Excel saves or exports data from any open workbook to an XML data file. (Inherited from AppEvents_Event.)
WorkbookBeforeXmlImport - Occurs before an existing XML data connection is refreshed or new XML data is imported into any open Microsoft Excel workbook. (Inherited from AppEvents_Event.)


这篇关于Excel加载项:Excel事件处理程序的新实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆