简体   繁体   English

如何将处理程序添加到Excel使用ExcelDNA计算事件

[英]How to add handlers to Excel Calculate Events with ExcelDNA

I would like to be able to listen to the BeginCalculate and EndCalculate events for all sheets in Excel from my ExcelDNA addin, and execute some intialization code. 我希望能够从我的ExcelDNA插件监听Excel中所有工作表的BeginCalculate和EndCalculate事件,并执行一些初始化代码。 Is there a way to do this? 有没有办法做到这一点?

There was some discussion on the Excel-DNA Google group here: https://groups.google.com/group/exceldna/browse_frm/thread/58da470968d6658b This shows how to handle the C API ON.RECALC event, which fires after a recalculation. 关于Excel-DNA Google小组的讨论如下: https ://groups.google.com/group/exceldna/browse_frm/thread/58da470968d6658b这显示了如何处理C API ON.RECALC事件,该事件在重新计算后触发。

You can get also hold of the Excel Application COM object with a call to ExcelDnaUtil.Application , and then register your event handlers for the Application events. 您还可以通过调用ExcelDnaUtil.Application获得Excel Application COM对象,然后为Application事件注册事件处理程序。 The Application events are documented here: http://msdn.microsoft.com/en-us/library/office/jj734018.aspx and you might be interested in AfterCalculate . 此处记录了应用程序事件: http : //msdn.microsoft.com/zh-cn/library/office/jj734018.aspx ,您可能对AfterCalculate感兴趣。

I don't know of any Excel events that fire before recalculation. 我不知道重新计算之前会触发任何Excel事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM