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。
enabled?: boolean;
属性值
boolean
id
清单中指定的控件的标识符。
id: string;
属性值
string