Office.Tab interface

Represents an individual tab and the state it should have. For code examples, see Enable and Disable Add-in Commands and Create custom contextual tabs.

Remarks

Requirement set: RibbonAPI 1.1

Examples

// Create an Office.Tab object (a contextual tab), set its visibility
// and add it to the ribbon.
async function showDataTab() {
    // Create the Office.Tab object.
    const myContextualTab = { id: "CtxTab1", visible: true };
    const ribbonUpdater = { tabs: [ myContextualTab ] };
    await Office.ribbon.requestUpdate(ribbonUpdater);
}

Properties

controls

Specifies one or more of the controls in the tab, such as menu items, buttons, etc.

groups

Specifies one or more of the control groups on the tab.

id

Identifier of the tab as specified in the manifest.

visible

Specifies whether the tab is visible on the ribbon. Used only with contextual tabs.

Property Details

controls

Specifies one or more of the controls in the tab, such as menu items, buttons, etc.

controls?: Control[];

Property Value

Remarks

When the Tab object is part of an Office.RibbonUpdaterData object passed to the requestUpdate method of Office.Ribbon, this property specifies the IDs of the controls whose enabled status is to be changed. However, if there is a groups property on the tab, then this property is ignored and the controls properties of the specified groups must be used to change enabled status.

groups

Specifies one or more of the control groups on the tab.

groups?: Group[];

Property Value

Remarks

When the Tab object is part of an Office.RibbonUpdaterData object passed to the requestUpdate method of Office.Ribbon, the controls properties of the various Office.Group objects specify which controls have their enabled status changed; the controls property of the Tab object is ignored.

Requirement set: RibbonAPI 1.1

id

Identifier of the tab as specified in the manifest.

id: string;

Property Value

string

Examples

// Office.Tab objects are properties of ribbon updater objects that are passed to the 
// Office.ribbon.requestUpdate method. The following shows how to set the visibility of 
// a custom contextual tab.

async function showDataTab() {
    await Office.ribbon.requestUpdate({
        tabs: [
            {
                id: "CtxTab1",
                visible: true
            }
        ]});
}

// The the following does the same thing in TypeScript.

const showDataTab = async () => {
    const myContextualTab: Office.Tab = { id: "CtxTab1", visible: true };
    const ribbonUpdater: Office.RibbonUpdaterData = { tabs: [ myContextualTab ] };
    await Office.ribbon.requestUpdate(ribbonUpdater);
}

visible

Specifies whether the tab is visible on the ribbon. Used only with contextual tabs.

visible?: boolean;

Property Value

boolean

Remarks

Requirement set: RibbonAPI 1.2

Examples

// Office.Tab objects are properties of ribbon updater objects that are passed to the 
// Office.ribbon.requestUpdate method. The following shows how to set the visibility of 
// a custom contextual tab.

async function showDataTab() {
    await Office.ribbon.requestUpdate({
        tabs: [
            {
                id: "CtxTab1",
                visible: true
            }
        ]});
}

// The following does the same thing in TypeScript.

const showDataTab = async () => {
    const myContextualTab: Office.Tab = { id: "CtxTab1", visible: true };
    const ribbonUpdater: Office.RibbonUpdaterData = { tabs: [ myContextualTab ] };
    await Office.ribbon.requestUpdate(ribbonUpdater);
}