CommandBarControls
Methods and properties of the CommandBarControls object.
Methods
CommandBars(CommandBarId).Controls.Add(10).Controls.Add()
When the Enum value is 10 in CommandBars(CommandBarId).Controls.Add(), a drop-down custom element is added. Use the Add() method to add new custom elements to the drop-down box. For more information about setting properties for a new custom element, see A single custom element.
-
Syntax
expression.CommandBars(CommandBarId).Controls.Add(10).Controls.Add()Expression: An Application object.
-
Example
async function example() { await instance.ready(); const app = instance.Application; // Get the controls for the Start tab. const controls = await app.CommandBars('StartTab').Controls; // Add a drop-down list as a custom element. const control = await controls.Add(10); control.Caption = 'Drop-down list'; // Get the controls of the drop-down list. const popupControls = await control.Controls; // Add a custom element inside the drop-down list. const button = await popupControls.Add(1); button.Caption = 'Drop-down button 1'; }
Properties
CommandBars(CommandBarId).Controls.Add(10).Controls.Item()
A custom element in the drop-down list.
-
Syntax
expression.CommandBars(CommandBarId).Controls.Add(10).Controls.Item(Index)expressionrepresents the document type application object. -
Parameters
Property
Data type
Required
Description
Index
Number
Yes
The custom element at the Index position in the drop-down box.
-
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Get the Controls object for the StartTab command bar. const controls = await app.CommandBars('StartTab').Controls; // Add a custom element: a drop-down box. const control = await controls.Add(10); control.Caption = 'Drop-down box'; // Get the controls of the new drop-down box. const popupControls = control.Controls; // Add a custom element to the drop-down box. const button = popupControls.Add(1); button.Caption = 'Drop-down button 1'; // Get the first custom element in the drop-down box. const item1 = await popupControls.Item(1); item1.Caption = 'Change drop-down button'; }