且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将自定义功能区组添加到 Word 2007 中现有的自定义功能区组

更新时间:2022-11-19 10:16:22

idQ 是正确的方法.此属性允许您指定一个合格的 id,即命名空间中的一个 id.mso 等一些命名空间是内置的,但也可以指定自定义命名空间.

idQ is the right way to go. This attribute allows you specify a qualified id, i.e. an id within a namespace. Some namespaces such as mso are built in, but custom namespaces can also be specified.

关键是您需要 customUI 元素中的 xmlns:foo="bar" 属性与 customUI 中声明的命名空间相匹配> 您尝试扩展的第 3 方加载项.

The key is that you need a xmlns:foo="bar" attribute in your customUI element that matches the namespace declared within the customUI of the 3rd party add-in you are trying to extend.

例如,假设我有以下第 3 方加载项的 XML:

For example, suppose I have the XML for the following 3rd party add-in:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mso:customUI xmlns:mso="http://schemas.microsoft.com/office/2009/07/customui"
              xmlns:foo="bar">
  <mso:ribbon>
    <mso:tabs>
      <mso:tab idQ="foo:someTab" label="an extensible custom tab">
        <mso:group id="someGroup" label="a custom group">
          <mso:button id="someButton" label="button" />
        </mso:group>
      </mso:tab>
    </mso:tabs>
  </mso:ribbon>
</mso:customUI>

现在,我想用另一个加载项或模板中的新组扩展现有的 foo:someTab.我在新加载项中定义了一个 customUI,确保在 customUI 元素中指定相同的命名空间属性.然后我使用 idQ="foo:someTab":

Now, I want to extend the existing foo:someTab with a new group in another add-in or template. I define a customUI in the new add-in, making sure to specify the same namespace attribute in the customUI element. I then reference the existing tab using idQ="foo:someTab":

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <mso:customUI xmlns:mso="http://schemas.microsoft.com/office/2009/07/customui"
                  xmlns:foo="bar">
      <mso:ribbon>
        <mso:tabs>
          <mso:tab idQ="foo:someTab" label="an extensible custom tab">
            <mso:group id="someOtherGroup" label="a different custom group">
              <mso:button id="someOtherButton" label="a different button" />
            </mso:group>
          </mso:tab>
        </mso:tabs>
      </mso:ribbon>
    </mso:customUI>

这会在一个自定义选项卡上生成两个组.可以使用相同的方法扩展组和其他容器控件.

This results two groups on a single custom tab. The same approach can be used to extend groups and other container controls.

我通过仔细研究 Office 2010 功能区 UI XSD.不幸的是,它在 XSD 本身之外的记录很差.

I learned this through careful study of the Office 2010 Ribbon UI XSD. Unfortunately, it's poorly documented outside of the XSD itself.