Office.Tab interface
個々のタブと、必要な状態を表します。 コード例については、「 アドイン コマンドの可用性を変更する」 および「 カスタム コンテキスト タブを作成する」を参照してください。
注釈
要件セット: RibbonApi 1.1
使用元
例
// 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);
}
プロパティ
| controls | タブ内の 1 つ以上のコントロール (メニュー項目、ボタンなど) を指定します。 |
| groups | タブ上の 1 つ以上のコントロール グループを指定します。 |
| id | マニフェストで指定されているタブの識別子。 |
| visible | タブをリボンに表示するかどうかを指定します。 コンテキスト タブでのみ使用されます。 |
プロパティの詳細
controls
タブ内の 1 つ以上のコントロール (メニュー項目、ボタンなど) を指定します。
controls?: Control[];
プロパティ値
注釈
Tab オブジェクトが Office.Ribbon の requestUpdate メソッドに渡された Office.RibbonUpdaterData オブジェクトの一部である場合、このプロパティは、有効状態を変更するコントロールの ID を指定します。 ただし、タブに groups プロパティがある場合、このプロパティは無視され、指定されたグループの controls プロパティを使用して有効ステータスを変更する必要があります。
groups
タブ上の 1 つ以上のコントロール グループを指定します。
groups?: Group[];
プロパティ値
注釈
Tab オブジェクトが Office.Ribbon の requestUpdate メソッドに渡された Office.RibbonUpdaterData オブジェクトの一部である場合、さまざまな Office.Group オブジェクトの controls プロパティによって、有効状態が変更されたコントロールが指定されます。Tab オブジェクトの controls プロパティは無視されます。
要件セット: RibbonApi 1.1
例
/**
* Shows or hides a contextual tab.
*/
async function setContextualTabVisibility(visible: boolean) {
await Office.ribbon.requestUpdate({
tabs: [
{
id: "ContextualTab1",
visible: visible,
groups: [
{
id: "TableToolsGroup",
controls: [
{ id: "FormatTableButton", enabled: true },
{ id: "SortTableButton", enabled: true },
],
},
],
},
],
});
}
id
マニフェストで指定されているタブの識別子。
id: string;
プロパティ値
string
例
// 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
タブをリボンに表示するかどうかを指定します。 コンテキスト タブでのみ使用されます。
visible?: boolean;
プロパティ値
boolean
注釈
要件セット: RibbonApi 1.2
例
// 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);
}