当用户单击Word中的“插入图表”时接收事件
我试图在用户在 Word 2007/2010 中插入图表时拦截事件。我知道使用 VBA 您可以将事件绑定到功能区界面上的某些按钮。但是,图表插入不会触发任何事件。我想知道与办公自动化的 VBA 相比,VSTO 是否公开了更多的对象和事件。任何意见或指示表示赞赏。
I'm trying to intercept events when the user inserts a chart in Word 2007/2010. I know that using VBA you can bind events to certain buttons on the ribbon interface. However, chart insertion does not fire any events. I'm wondering if VSTO exposes more objects and events compared to VBA for office automation. Any comments or pointers are appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不会。VSTO 绝对不会暴露更多事件,并且在某些方面限制了您使用 IExtensibility 可以接收的事件。
也就是说,据我所知,“新图表”没有“明确”的事件。
但您仍然有一些选择。
一种方法是观看 Doc.Changed 并检测图表的添加。不一定容易,但可行。
另一种可能是浏览旧的工具栏和工具栏命令集合,找到“添加图表”菜单或工具栏项并接收其单击事件。我以前曾使用该技术来覆盖文件/保存等内容。这并不是万无一失的,但它可以对某些事情起作用......
No. VSTO doesn't expose any more events definitely and in some ways limits events over what you could receive using IExtensibility.
That said, as far as I know, there's no "explicit" event for "new chart".
But you still have a few options.
One would be to watch Doc.Changed and detect the addition of a chart. Not necessarily easy, but doable.
another might be to navigate through the old Toolbars and toolbars commands collections, find the "ADD CHART" menu or toolbar item and sink it's click event. I've used that technique to override things like FILE/SAVE, etc before. It's not foolproof but it can work for some things...
不幸的是,VSTO 只是 Office Interop 库的托管包装器,因此它没有比使用 Interop 库更多的钩子。它只是让插件开发变得更加容易,并为我们的设计师提供帮助和支持
Unfortunately VSTO is only a managed wrapper around the Office Interop libraries, so it has no more hooks than using the Interop libraries. It just makes add-in development much easier with helpers and giving us designer support