メニューは、オプションのリストを定義します。 各メニュー項目は、関数を実行したり、作業ウィンドウを表示したりします。
注:
この記事は、要素の属性に関する重要な情報を含む基本的な コントロール リファレンス記事 に精通していることを前提としています。
メニュー コントロールでは、次のことが定義されます。
- ルート レベルのメニュー コントロール。
- メニュー項目の一覧。
PrimaryCommandSurface 拡張ポイントと共に使用すると、ルート メニュー項目はリボン上のボタンとして表示されます。 ボタンを選択すると、メニューがドロップダウン リストとして表示されます。 サブメニューはサポートされません。
ContextMenu 拡張ポイントで使用すると、ルート メニュー項目がコンテキスト メニューに表示されます。 ルート項目を選択すると、メニュー項目がサブメニューとして表示されます。 サブメニューのレベルは 1 つしかサポートされていないため、いずれの項目自体もサブメニューにすることはできません。
子要素
| 要素 | 必須 | 説明 |
|---|---|---|
| Label | はい | メニューのテキストです。 |
| Supertip | はい | このメニューのスーパーヒント。 重要: スーパーヒントは Office デスクトップ クライアントでのみサポートされています。 |
| Icon | はい | メニューのの画像。 |
| <アイテム> | はい | メニュー内に表示する項目のコレクション。 各項目の <Item> 要素が含まれます。 |
| OverriddenByRibbonApi | 不要 | カスタム コンテキスト タブをサポートするアプリケーションとプラットフォームの組み合わせにメニューを表示するかどうかを指定します。 使う場合は、 最初の 子要素である必要があります。 |
Label
唯一の属性 resid を使用してメニュー名のテキストを指定します。resid は 32 文字以内で指定でき、Resources 要素の子である <ShortStrings> 要素の <String> 要素の id 属性の値に設定する必要があります。
アドインの種類: 作業ウィンドウ、メール
次の VersionOverrides スキーマでのみ有効です:
- 作業ウィンドウ 1.0
- メール 1.0
- メール 1.1
詳細については、「 アドインのみのマニフェストのバージョンのオーバーライド」を参照してください。
次の要件セットに関連付けられています:
- 親 <VersionOverrides> が Taskpane 1.0 型の場合、AddinCommands 1.1。
- 親 <VersionOverrides> が Mail 1.0 型の場合、Mailbox 1.3。
- 親 <VersionOverrides> が Mail 1.1 型の場合、Mailbox 1.5。
例
次の例では、メニューに 2 つの項目があります。 1 つ目は作業ウィンドウを表示します。 2 つ目は関数を実行します。 メニューは、アドインがコンテキスト タブをサポートするプラットフォームで実行されている場合は表示 されないように 構成されています。 詳細については、「 カスタム コンテキスト タブがサポートされていない場合に代替 UI エクスペリエンスを実装する」を参照してください。
<Control xsi:type="Menu" id="Contoso.TestMenu2">
<OverriddenByRibbonApi>true</OverriddenByRibbonApi>
<Label resid="residLabel3" />
<Supertip>
<Title resid="residLabel" />
<Description resid="residToolTip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="icon1_32x32" />
<bt:Image size="32" resid="icon1_32x32" />
<bt:Image size="80" resid="icon1_32x32" />
</Icon>
<Items>
<Item id="ShowMainTaskPane">
<Label resid="residLabel3"/>
<Supertip>
<Title resid="residLabel" />
<Description resid="residToolTip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="icon1_32x32" />
<bt:Image size="32" resid="icon1_32x32" />
<bt:Image size="80" resid="icon1_32x32" />
</Icon>
<Action xsi:type="ShowTaskpane">
<TaskpaneId>MyTaskPaneID1</TaskpaneId>
<SourceLocation resid="residUnitConverterUrl" />
</Action>
</Item>
<Item id="GetData">
<Label resid="residLabel5"/>
<Supertip>
<Title resid="residLabel" />
<Description resid="residToolTip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="icon4_32x32" />
<bt:Image size="32" resid="icon4_32x32" />
<bt:Image size="80" resid="icon4_32x32" />
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>getData</FunctionName>
</Action>
</Item>
</Items>
</Control>
次の例では、メニューの 2 番目の項目は、アドインがコンテキスト タブをサポートするプラットフォームで実行されている場合は表示 されないように 構成されています。 詳細については、「 カスタム コンテキスト タブがサポートされていない場合に代替 UI エクスペリエンスを実装する」を参照してください。
<Control xsi:type="Menu" id="Contoso.msgReadMenuButton">
<Label resid="menuReadButtonLabel" />
<Supertip>
<Title resid="menuReadSuperTipTitle" />
<Description resid="menuReadSuperTipDescription" />
</Supertip>
<Icon>
<bt:Image size="16" resid="red-icon-16" />
<bt:Image size="32" resid="red-icon-32" />
<bt:Image size="80" resid="red-icon-80" />
</Icon>
<Items>
<Item id="ShowMainTaskPane">
<Label resid="residLabel3"/>
<Supertip>
<Title resid="residLabel" />
<Description resid="residToolTip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="icon1_32x32" />
<bt:Image size="32" resid="icon1_32x32" />
<bt:Image size="80" resid="icon1_32x32" />
</Icon>
<Action xsi:type="ShowTaskpane">
<TaskpaneId>MyTaskPaneID1</TaskpaneId>
<SourceLocation resid="residUnitConverterUrl" />
</Action>
</Item>
<Item id="msgReadMenuItem1">
<OverriddenByRibbonApi>true</OverriddenByRibbonApi>
<Label resid="menuItem1ReadLabel" />
<Supertip>
<Title resid="menuItem1ReadLabel" />
<Description resid="menuItem1ReadTip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="red-icon-16" />
<bt:Image size="32" resid="red-icon-32" />
<bt:Image size="80" resid="red-icon-80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>getItemClass</FunctionName>
</Action>
</Item>
</Items>
</Control>
Office Add-ins