积极答复者
VSTO 拦截Office自带功能的问题

问题
答案
-
根据您的的描述, 您可以自定义Office Ribbon实现您的功能,在Visual Studion中创建Word Add-in项目,选中项目右键添加新项目,选择Ribbon(Xml),命名为CustomerRibbon,添加如下代码:
<?xml version="1.0" encoding="UTF-8"?> <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load"> <commands> <command idMso="BookmarkInsert" onAction="InsertBookmarkAction"/> </commands> <!--<ribbon> <tabs> <tab idMso="TabInsert"> <group> </group> </tab> </tabs>--> <!--</ribbon>--> </customUI>
打开CustomerRibbon.cs,添加如下代码:
public void InsertBookmarkAction(Office.IRibbonControl control, bool cancelDefault) { //您的逻辑处理代码 }
打开ThisAddIn.cs文件,添加如下代码:
protected override Office.IRibbonExtensibility CreateRibbonExtensibilityObject() { return new CustomerRibbon(); }
更多详细信息,请参考:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
- 已标记为答案 HeroHua0509 2016年3月3日 11:59
全部回复
-
根据您的的描述, 您可以自定义Office Ribbon实现您的功能,在Visual Studion中创建Word Add-in项目,选中项目右键添加新项目,选择Ribbon(Xml),命名为CustomerRibbon,添加如下代码:
<?xml version="1.0" encoding="UTF-8"?> <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load"> <commands> <command idMso="BookmarkInsert" onAction="InsertBookmarkAction"/> </commands> <!--<ribbon> <tabs> <tab idMso="TabInsert"> <group> </group> </tab> </tabs>--> <!--</ribbon>--> </customUI>
打开CustomerRibbon.cs,添加如下代码:
public void InsertBookmarkAction(Office.IRibbonControl control, bool cancelDefault) { //您的逻辑处理代码 }
打开ThisAddIn.cs文件,添加如下代码:
protected override Office.IRibbonExtensibility CreateRibbonExtensibilityObject() { return new CustomerRibbon(); }
更多详细信息,请参考:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
- 已标记为答案 HeroHua0509 2016年3月3日 11:59
-
David_JunFeng 非常感谢您的回答
您提供的方式是使用 Ribbon xml的方式去实现的
我现在已有用设计器的Ribbon,那样的话是该如果做呢
另外,其实我想拦截Office word中插入--书签 -这个按钮的事件