Command Bar Controls
Initially, one of the most confusing aspects of the Office menu system is that the items that appear on a menubar are not menus, or even names of menus. Rather, they are controls of type CommandBarControl. Command bar controls can be added to a menubar, toolbar, menu, submenu, or shortcut menu.
Every command bar control is an object of type CommandBarControl. In addition, every command bar control is an object of one of the following three object types:
CommandBarButton
CommandBarComboBox
CommandBarPopup
This allows the various types of command bar controls to possess a common set of properties and methods (those of the CommandBarControl object), as well as an additional set of properties and methods that reflects the diversity of these controls. (After all, text boxes are quite different from popup controls, for instance.)
Creating a New Command Bar Control
To create and add a command bar control to a command bar, use the Add method of the CommandBarControls collection. This method returns a CommandBarButton, CommandBarComboBox, or CommandBarPopup object, depending on the value of the Type
parameter (see later in this section). The syntax is:
CommandBarControlsObject
.Add(Type, Id, Parameter,
_Before, Temporary
)
Type
is the type of control to be added to the specified command bar. Table 21-1 shows the possible values for this parameter, along with the corresponding control and the return type of the Add method.
Table 21-1. msoControlType Values for the Type Parameter ...
Get Writing Word Macros, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.