如何在 C# Word VSTO 加载项中使用功能区 XML 自定义快速访问工具栏 (QAT),同时仍允许用户随后修改 QAT?
我正在使用 Visual Studio 2010 创建 VSTO Word 2007 C# 加载项。我想将控件添加到 Word 的快速访问工具栏 (QAT),以便用户了解这些控件公开的功能(它们替换内置的 Word 功能,即. 撤消/重做。)我使用功能区 XML 来自定义功能区,因此为了向 QAT 添加控件,我必须使用
。不幸的是,这样做会导致用户无法通过添加他们希望在其中看到的控件来进一步自定义 QAT。 (“自定义快速访问工具栏”下拉菜单中所有可以添加的命令均呈灰色显示,“更多命令”按钮也呈灰色显示。)执行此操作还会从用户之前可能拥有的 QAT 中删除任何控件为了他们的方便而放置他们。
我用来重现此问题的功能区 XML 是:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load">
<ribbon startFromScratch="true">
</ribbon>
</customUI>
我想知道的是:
1) 有没有办法允许用户在将我自己的控件添加到 QAT 后修改 QAT? (理想情况下,我会保留用户以前的 QAT 自定义设置。)或者,
2) 是否有另一种方法可以将我的控件放入 QAT 中,而不会删除用户的自定义设置并允许用户随后修改 QAT?
谢谢!
I am creating a VSTO Word 2007 C# Add-In using Visual Studio 2010. I want to add controls to Word's Quick Access Toolbar (QAT) so that a user becomes aware of the functionality that these controls expose (they replace builtin Word functionality, viz. undo/redo.) I am using ribbon XML to customize the ribbon, so in order to add controls to the QAT, I must use <ribbon startFromScratch="true">
. Unfortunately, doing so disables the users ability to further customize the QAT by adding back controls they would like to see there. (The "Customize Quick Access Toolbar" drop down menu has all the commands that could be added grayed out, and the "More Commands" button is also grayed out.) Doing this also removes any controls from the QAT that a user may have previously put their for their convenience.
The ribbon XML I use to reproduce this problem is:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load">
<ribbon startFromScratch="true">
</ribbon>
</customUI>
What I want to know is:
1) Is there a way to allow a user to modify the QAT after adding my own controls to the QAT? (Ideally I would preserve the user's previous QAT customizations.) Alternatively,
2) is there another way to get my controls into the QAT that would not erase the user's customizations and allow the user subsequently to modify the QAT?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为我要采取的方法是修改用户的自定义 QAT 文件(对于 WinXP):
C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Office\Word.qat
我还没有不过,我还没有时间实施,所以我不确定是否能够在 Word 锁定文件之前或在 Word 加载文件之前修改该文件。也许我可以让 Word 重新加载它。
I think the approach I am going to take is to modify the user's custom QAT file located at (for WinXP):
C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\Office\Word.qat
I haven't had the time to implement yet, though, so I'm not sure that I will be able to modify the file before Word locks it, or in time for Word to load it. Perhaps I can cause Word to reload it.
如果您使用
startFromScratch="true"
您总会遇到这个问题。如果您要覆盖撤消/重做等操作,为什么不直接用您的功能覆盖这些按钮呢? 暂时重新调整 Office Fluent 功能区上命令的用途If you use
startFromScratch="true"
you'll always get this problem. If you're over-riding things like undo/redo, why not just override those buttons with your functions? Temporarily Repurpose Commands on the Office Fluent Ribbon