简体   繁体   English

在任何选项卡上获取事件单击MS Word VSTO中的功能区添加

[英]Get event on any tab click in ribbon in MS word VSTO add in

I have created a MsWordAddin using VSTO addin in visual studio for MS Office 2010.Till now I have added a new tab in Ribbon and customized task Pane. 我已经在Visual Studio中为MS Office 2010使用VSTO插件创建了一个MsWordAddin。到目前为止,我已经在Ribbon和自定义任务窗格中添加了一个新选项卡。 What now I want is to get a event when user select any tab on Ribbon,so i can evaluate what user has performed on this event eg user select Page layout tab and change Page orientation from horizontal to landscape. 现在我想要的是当用户选择功能区上的任何选项卡时得到一个事件,因此我可以评估用户对此事件执行的操作,例如,用户选择“页面布局”选项卡并将页面方向从水平更改为横向。

I found SelectionChange,BeforeRightClick,BeforeDoubleClick document events,but they are not what i want. 我发现SelectionChange,BeforeRightClick,BeforeDoubleClick文档事件,但它们不是我想要的。

Is there any way to get event in MS Word or any other workaround to evaluate such scenario ? 有没有办法在MS Word中获取事件或任何其他变通办法来评估这种情况?


I want to evaluate as same way as RibbonHero Hope this clears my question very well. 我想像RibbonHero一样进行评估。希望这可以很好地解决我的问题。

No, the Fluent UI (aka Ribbon UI), nor the Word object model, doesn't provide any event for that. 不,Fluent UI(也称为Ribbon UI)或Word对象模型都没有为此提供任何事件。 If you have got your add-in's controls on a particular tab you may consider handling callbacks that should be fired when the tab is going to be shown. 如果您在特定选项卡上具有外接程序的控件,则可以考虑处理将在显示该选项卡时触发的回调。

so i can evaluate what user has performed on this event eg user select Page layout tab and change Page orientation from horizontal to landscape. 这样我就可以评估用户对此事件执行的操作,例如,用户选择“页面布局”标签并将页面方向从水平更改为横向。

Instead, I'd suggest handling the Document's events . 相反,我建议处理Document的events

Try using MSAA ..You can get sample code https://code.msdn.microsoft.com/CSOfficeRibbonAccessibility-cd7fe67f#content 尝试使用MSAA ..您可以获得示例代码https://code.msdn.microsoft.com/CSOfficeRibbonAccessibility-cd7fe67f#content

I have implemented this and find very useful. 我已经实现了这一点,发现非常有用。

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

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