dariom
dariom

Reputation: 4583

Is it possible to programmatically add built-in command to Add-in ribbon tab?

We have built a Word Add-In using the Office Add-in platform SDKs (JavaScript).

The Add-In includes a custom ribbon tab (defined in the Manifest.xml). We've been asked to add the "Text Styles" built-in command button to the custom ribbon. It's possible to add this manually by right-clicking and customising the toolbar.

[enter image description here]

We'd like to roll this out to all users on a larger scale – is it possible to add this customisation programmatically through our Add-In (manifest.xml)?

I've tried to change the manifest.xml file to reference the StylesPane command but this wasn't successful. I've also researched other ways to customise the "Office Fluent Ribbon" by following the links in this GitHub repo, specifically Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3) | Microsoft Docs however these instructions seem to be targeted to the older COM add-in model for Office and not the newer JavaScript-based Office Add-in platform.

Is it even possible to add or reference built-in commands in a custom ribbon?

Upvotes: 0

Views: 743

Answers (2)

Emp
Emp

Reputation: 11

Late for you, but may help others. I found the answer to this while trying to solve it myself.

You can find the id (actually it is idMso) of the built in commands by hovering over them in the builtin Ribbon Customization tool. You just then need to add them to your custom addin xml. Greg Maxley covers this, though this information is buried in a paragraph part-way down. He also gives examples of of well formed xml references as go-bys. The look of the imageMso have changed over the years, but still the Names generally match the idMso they are related to. If not, you may find it here

Upvotes: 1

Eugene Astafiev
Eugene Astafiev

Reputation: 49397

You can insert built-in Office buttons into your custom control groups on the Office ribbon by using markup in the add-in's manifest. You can also insert entire built-in Office control groups into your custom ribbon tabs.

To insert a built-in Office control into a custom group, add an OfficeControl element as a child element in the parent element. The id attribute of the element is set to the ID of the built-in control. See Find the IDs of controls and control groups.

The following markup example adds the Office Superscript control to a custom group and positions it to appear just after a custom button:

<ExtensionPoint xsi:type="ContosoRibbonTab">
  <CustomTab id="Contoso.TabCustom2">
    <Group id="Contoso.TabCustom2.group1">
        <Label resid="residCustomTabGroupLabel"/>
        <Icon>
            <bt:Image size="16" resid="blue-icon-16" />
            <bt:Image size="32" resid="blue-icon-32" />
            <bt:Image size="80" resid="blue-icon-80" />
        </Icon>
        <Control xsi:type="Button" id="Contoso.Button1">
            <!-- information on the control omitted -->
        </Control>
        <OfficeControl id="Superscript" />
        <!-- other controls, as needed -->
    </Group>
    <Label resid="customTabLabel1" />
  </CustomTab>
</ExtensionPoint>

Read more about that in the Integrate built-in Office buttons into custom control groups and tabs article.

Upvotes: 2

Related Questions