问题
I find numerous examples on how to add a new group to an existing ribbon, and this works just fine.
What I cannot figure out is how I can add new controls to an existing group on an existing ribbon. Say I want to add my own command to the "Proofing" group on the "Review" tab.
I'm developing this in VS2010 for Office2010, but I guess the same approach would work on Office 2007 as well.
Any pointers or help is appreciated, or if it's not possible to do (without too much hacking) I can live with that as well.
回答1:
Unfortunately, this is not possible. You may only add controls to custom groups in Office 2007/2010.
The built-in groups are really a different thing than the custom groups that you may add. For example, you will see for example that the built-in groups such as the ones for font and paragraph formatting behave differently with respect to resizing the application window.
回答2:
While you cannont modify the built in groups, you can hide them. After hiding the built in group, you can replace it woth a look alike that you have added your controls to. You'll need to know the id of the group to hide and the contents of the group to recreate it. This site provides details: Change built-in groups in the Ribbon. One warning though, since you are not modifying the group, your recreated group will not reflect the changes in the standard in the group Microsoft makes in different versions of Office.
Here's custoumUI.xml that hides the built in Proofing group and replaces it with a copy of the Excel 2007 version of the group:
<?xml version="1.0"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<!-- Point to the Built-in tab to the ribbon -->
<tab idMso="TabReview">
<!-- Set visible to false for native Proofing group-->
<group idMso="GroupProofing" visible="false"/>
<!-- Add custom Proofing group -->
<group insertBeforeMso="GroupProofing" label="Proofing" id="DupProofing">
<button idMso="Spelling" size="large"/>
<toggleButton idMso="ResearchPane" size="large"/>
<button idMso="Thesaurus" size="large"/>
<button idMso="TranslationPane" size="large"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
来源:https://stackoverflow.com/questions/3861630/add-controls-to-existing-ribbon-group-in-office-vsto