Working with Command BarsThis content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
Microsoft® Office applications all share the same technology for creating menus and toolbars, and this technology is available to you through the command bars object model. In Office applications, there are three kinds of CommandBar objects: toolbars, menu bars, and pop-up menus. Pop-up menus are displayed in three ways: as menus that drop down from menu bars, as submenus that cascade off menu commands, and as shortcut menus. Shortcut menus (also called "right-click menus") are menus that appear when you right-click something.
Because the command bars object model is shared by all Office applications, you can write code to manipulate command bars that can be used in any Office application or custom application you develop. Everything you can do in a host application by using the Customize dialog box you also can do by using Microsoft® Visual Basic® for Applications (VBA) code. In addition, there are some things you can do only by using VBA code.
Understanding how to work with command bars in Office applications requires that you understand not only what they have in common across all applications (the command bars object model) but also how they differ within each application.
In This Section
- Understanding Application-Specific Command Bar Information
- Learn how each Microsoft® Office application stores command bar information in a different location and, in some cases, implements command bars in a different way.
- Manipulating Command Bars and Command Bar Controls with VBA Code
- Use objects, collections, properties, and methods to show, hide, and modify existing command bars and command bar controls, as well as create new ones.
- Working with Shared Office Components
- Search for files, use the Office Assistant, manipulate command bars, read and write document properties, read and write script, and hook add-ins to your Microsoft® Office application using a set of shared objects available in all Office applications.
- Referencing Shared Office Components
- Return a reference to a shared component object by using the appropriate properties.
- Working with the FileSearch Object
- Programmatically access the functionality of the Office File Open dialog box.
- Working with the Office Assistant
- Use the objects, methods, and properties of the Office Assistant object to programmatically control the Office Assistant.
- Working with Document Properties
- Use document properties to create, maintain, and track information about an Office document.
- Working with Scripts
- Access script, or insert script into a cell or range in a Microsoft® Excel worksheet, a Microsoft® PowerPoint® slide, a Microsoft® Word document, or Word Selection object.