简体   繁体   English

将控件添加到Office(VSTO)中的现有功能区组

[英]Add controls to existing ribbon group in Office (VSTO)

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. 我正在VS2010中为Office2010开发这个,但我想同样的方法也适用于Office 2007。

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. 任何指针或帮助都是值得赞赏的,或者如果不可能做到(没有太多黑客攻击),我也可以接受它。

Unfortunately, this is not possible. 不幸的是,这是不可能的。 You may only add controls to custom groups in Office 2007/2010. 您只能在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. 您需要知道要隐藏的组的ID以及要重新创建它的组的内容。 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. 但是有一个警告,因为您没有修改组,重新创建的组将不会反映Microsoft在不同版本的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: 这是custoumUI.xml,它隐藏了内置的校对组,并将其替换为该组的Excel 2007版本的副本:

<?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>

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

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