Office.Control interface

個々のコントロールまたはコマンド、およびそれに必要な状態を表します。

注釈

Control オブジェクトとそのプロパティを使用する方法を示すコード サンプルについては、「アドイン コマンドの可用性を変更する」および「カスタム コンテキスト タブを作成する」を参照してください。

要件セット: RibbonApi 1.1

使用元

// 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);
}

プロパティ

enabled

コントロールを有効にするか無効にするかを示します。 既定値は true です。

id

マニフェストで指定されているコントロールの識別子。

visible

カスタム タブでコントロールを表示するか非表示にするかを指定します。既定値は true です。

プロパティの詳細

enabled

コントロールを有効にするか無効にするかを示します。 既定値は true です。

enabled?: boolean;

プロパティ値

boolean

id

マニフェストで指定されているコントロールの識別子。

id: string;

プロパティ値

string

visible

カスタム タブでコントロールを表示するか非表示にするかを指定します。既定値は true です。

visible?: boolean;

プロパティ値

boolean

注釈

要件セット: RibbonApi 1.3

重要: ボタンとメニュー コントロールの表示は構成できますが、メニュー内の個々の項目の表示は構成できません。

// Hide the Export Report button from the ribbon.
const button: Office.Control = {
    id: "Contoso.ExportReportButton",
    visible: false
};

// Specify the button's parent group and tab.
const group: Office.Group = {
    id: "Contoso.ReportingGroup",
    controls: [button]
};
const tab: Office.Tab = {
    id: "Contoso.UserToolsTab",
    groups: [group]
};

// Apply the change to the ribbon.
const ribbonUpdater: Office.RibbonUpdaterData = { tabs: [tab] };
await Office.ribbon.requestUpdate(ribbonUpdater);