Edit

Office.Control interface

Represents an individual control or command and the state it should have.

Remarks

For code samples showing how to use a Control object and its properties, see Change the availability of add-in commands and Create custom contextual tabs.

Requirement set: RibbonApi 1.1

Used by

Examples

// This snippet enables a control (a button) in a custom ribbon tab.
// Note that "MyButton", "OfficeAddinTab1", and "CustomGroup111" are defined in the manifest.
const enableButton = async () => {
    const button: Control = { id: "MyButton", enabled: true };
    const parentGroup: Group = { id: "CustomGroup111", controls: [button] };
    const parentTab: Tab = { id: "OfficeAddinTab1", groups: [parentGroup] };
    const ribbonUpdater: RibbonUpdaterData = { tabs: [parentTab] };
    Office.ribbon.requestUpdate(ribbonUpdater);
}

Properties

enabled

Indicates whether the control should be enabled or disabled. The default is true.

id

Identifier of the control as specified in the manifest.

visible

Specifies whether the control is shown or hidden on a custom tab. The default is true.

Property Details

enabled

Indicates whether the control should be enabled or disabled. The default is true.

enabled?: boolean;

Property Value

boolean

id

Identifier of the control as specified in the manifest.

id: string;

Property Value

string

visible

Specifies whether the control is shown or hidden on a custom tab. The default is true.

visible?: boolean;

Property Value

boolean

Remarks

Requirement set: RibbonApi 1.3

Important: The visibility of buttons and menu controls can be configured, but the visibility of individual items within a menu can't be configured.