Microsoft Office Tutorials and References
In Depth Information
12.1.2 The CommandBar Object
12.1.2 The CommandBar Object
Toolbars, menu bars, menus, submenus, and shortcut menus are all CommandBar objects. (A
shortcut menu is a menu that pops up in response to a right mouse click.) Thus, every item
pictured in Figure 12-2 i s a command bar except the popup controls and the button control.
Of course, toolbars, menu bars, and shortcut menus are "top level" objects, whereas menus and
submenus emanate from toolbars, menu bars, or shortcut menus.
It is important to note that Office VBA does not treat each of these CommandBar objects in the
same way. For instance, the Count property of the CommandBars collection counts only the
toplevel items: menu bars, toolbars, and shortcut menus. It does not count menus or submenus. Also,
the Add method of the CommandBars collection can be used to create toolbars or menu bars, but
not menus or submenus.
The CommandBar object has a Type property that can assume one of the constants in the
following enum:
Enum MsoBarType
msoBarTypeNormal = 0 ' toolbar
msoBarTypeMenuBar = 1 ' menu bar
msoBarTypePopup = 2 ' menu, submenu, or shortcut menu
End Enum
12.1.3 Command-Bar Controls
The items on a toolbar, menu bar, menu, or submenu are actually controls, called command-bar
controls ; that is, they are CommandBarControl objects. As we will see, there are various types of
command-bar controls, falling into two broad categories: custom command-bar controls
(including custom text boxes, drop-down list boxes, and combo boxes) and built-in command-bar
controls. Note that command-bar controls are not the same as the controls that we can place on a
UserForm; they are designed specifically for toolbars and menus.
There are two special types of custom command-bar controls that are not typical of other types of
controls. These are Popup controls and Button controls.
Search JabSto ::

Custom Search