This method adds a CommandBarControl object to the CommandBarControls collection of a CommandBar control.
cmdbarctrls.Add([type], [key])
Reference to the new control, which is a CommandBarButton, CommandBarComboBox, or CommandBarMenuBar.
The following table shows the possible values for the type parameter.
Constant |
Value |
Description |
cbrButton | 0 | The control added is a CommandBarButton. |
cbrComboBox | 1 | The control added is a CommandBarComboBox. |
cbrMenuBar | 2 | The control added is a CommandBarMenuBar. |
You can add controls in any order. If the value for before is not a valid key for a control in the collection, Add raises an error.
The following code example shows how to add a button.
Dim B As CommandBarButton
Set B = CommandBar1.Controls.Add(cbrButton)
B.Style = cbrCheck