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

发布于 2024-09-25 18:58:48 字数 214 浏览 7 评论 0原文

我找到了很多关于如何向现有功能区添加新组的示例,这效果很好。

我不知道如何将新控件添加到现有功能区上的现有组中。假设我想将自己的命令添加到“审阅”选项卡上的“校对”组中。

我正在 VS2010 中为 Office2010 开发此程序,但我想同样的方法也适用于 Office 2007。

任何指示或帮助都是值得赞赏的,或者如果不可能(没有太多的黑客行为)我也可以忍受。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅黛梨妆こ 2024-10-02 18:58:48

不幸的是,这是不可能的。您只能将控件添加到 Office 2007/2010 中的自定义组。

内置组实际上与您可以添加的自定义组不同。例如,您将看到内置组(例如用于字体和段落格式的组)在调整应用程序窗口大小方面的行为有所不同。

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.

苍景流年 2024-10-02 18:58:48

虽然您无法修改内置组,但可以隐藏它们。隐藏内置组后,您可以将其替换为与已添加控件的外观相似的组。您需要知道要隐藏的组的 ID 以及该组的内容才能重新创建它。此网站提供详细信息:更改功能区中的内置组。但需要注意的是,由于您没有修改该组,因此重新创建的组将不会反映 Microsoft 在不同版本的 Office 中对组标准所做的更改。

下面的 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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文