This topic describes the property and the method of CommandBarControls.
Method
CommandBars(CommandBarId).Controls.Add(10).Controls.Add()
If you set Enum to 10 in CommandBars(CommandBarId).Controls.Add(), you can add a drop-down box to add custom items. You can add custom items in the drop-down box by using the Add() method. For more information, 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; // Obtain the Start tab for element customization. const controls = await app.CommandBars('StartTab').Controls; // Add a drop-down list. const control = await controls.Add(10); control.Caption = 'Drop-down list'; // Obtain the drop-down box. const popupControls = await control.Controls; // Add a custom element to the drop-down list. const button = await popupControls.Add(1); button.Caption = 'Drop-down button 1'; }
Property
CommandBars(CommandBarId).Controls.Add(10).Controls.Item()
Creates a custom item in the drop-down box.
Syntax
expression.CommandBars(CommandBarId).Controls.Add(10).Controls.Item(Index)expression: the document type application object.
Parameters
Property
Type
Required
Description
Index
Number
Yes
Customizes the item in the drop-down box numbered Index.
Example
//@file=base.docx async function example() { await instance.ready(); const app = instance.Application; // Create a custom StartTab item. const controls = await app.CommandBars('StartTab').Controls; // Add a custom item: DropDownBox. const control = await controls.Add(10); control.Caption ='DropDownBox'; // Obtain DropDownBox. const popupControls = control.Controls; // Customize an item in the drop-down box. const button = popupControls.Add(1); button.Caption ='DropDownButton 1'; // Customize the item in the first drop-down box. const item1 = await popupControls.Item(1); item1.Caption ='Modify DropDownButton'; }