在VSTO Addin for Excel中,如何处理活动工作表中的按钮单击事件? [英] In VSTO Addin for Excel how to handle a button click event from active worksheet?

查看:205
本文介绍了在VSTO Addin for Excel中,如何处理活动工作表中的按钮单击事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我正在使用带有VSTO的VB.NET 2010开发Excel 2010加载项.

Currently I am developing an Excel 2010 Addin using VB.NET 2010 with VSTO.

活动工作表上有一个按钮,其单击事件将由其自己的VBA代码处理.

The active worksheet has a button, its click event will be handled by its own VBA code.

现在,我想在Addin中处理相同的按钮单击事件,而不影响其原始VBA功能.是否有可能?而我该如何实现呢?

Now I would like to handle the same button click event in Addin without affecting its original VBA function. Is it possible? And how can I achieve this?

此任务的先决条件是不允许在Excel模板(包括其VBA代码)上进行任何更改.这就是为什么我尝试通过VB.NET进行事件处理.

The pre-requisite of this task is that nothing is allowed to be changed on the Excel Template (including its VBA code). That's why I am trying from the event handling by VB.NET.

触发点是单击Excel模板中的按钮,然后它肯定会引发某些事件,并且该事件肯定会由VBA宏处理,但是我想在VB中添加另一个侦听器(事件处理程序) .Net到同一事件,因此我可以执行一些其他任务.

The trigger point is that the button in the Excel template is clicked, then it will surely raise certain event, and such event will certainly be handled by VBA macro, but I would like to add another listener (event handler) in VB.Net to the same event, so I can do some additional task.

有人知道如何添加这样的事件处理程序吗?

Is there anyone know how to add such event handler?

谢谢.

推荐答案

就您而言,这很容易,您不需要创建按钮,只需使用它的名称即可.

In your case it is easier, you don't need to create a button, you can just use it's name.

这篇关于在VSTO Addin for Excel中,如何处理活动工作表中的按钮单击事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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