Add controls to existing ribbon group in Office (VSTO)

最后都变了- 提交于 2019-12-05 06:25:26

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.

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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!