Export (0) Print
Expand All

Manipulating Command Bars and Command Bar Controls with VBA Code

This 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.

The command bars object model exposes a wealth of objects, collections, properties, and methods that you can use to show, hide, and modify existing command bars and command bar controls, and create new ones. In addition, you can specify a Microsoft® Visual Basic® for Applications (VBA) procedure to run when a user clicks a command bar button or to respond to events triggered by a command bar or command bar control. The following sections provide a broad overview of the kinds of things you can do in your custom Microsoft® Office applications and how to accomplish them.

Note   Many of the examples in this section refer to the "Menu Bar" CommandBar object. This is the name of the main menu bar in Microsoft® Word, Microsoft® PowerPoint®, and Microsoft® Access. The main menu bar in Microsoft® Excel is called "Worksheet Menu Bar." To experiment with sample code that refers to the "Menu Bar" CommandBar object in Excel, simply change the reference from "Menu Bar" to "Worksheet Menu Bar."

In This Section

Getting Information About Command Bars and Controls
Examine the dozens of command bars and controls built in to each Microsoft® Office application.
Creating a Command Bar
Create toolbars by using the Customize dialog box or by using Microsoft® Visual Basic® for Applications (VBA) code in any Office application.
Hiding and Showing a Command Bar
Hide or display a toolbar, and specify where it will appear on the screen.
Copying a Command Bar
Use Microsoft® Visual Basic® for Applications (VBA) code to copy an existing command bar.
Deleting a Command Bar
Delete toolbars and menu bars from the Customize dialog box or by using Microsoft® Visual Basic® for Applications (VBA).
Preventing Users from Modifying Custom Command Bars
Make sure users of your custom application cannot delete or disable your custom command bars by using the Customize dialog box.
Working with Personalized Menus
Turn on personalized menus for all command bars in an application or for individual command bars only.
Working with Images on Command Bar Buttons
Understand how to use images on your own command bar buttons.
Working with Command Bar Controls
Create references to controls on a command bar, and access all available properties and methods of that control.
Working with Command Bar Events
Use command bar event procedures to run your own code in response to an event, and use these event procedures to substitute your own code for the default behavior of a built-in control.

Related Sections

Working with Command Bars
Write code to manipulate command bars that can be used in any Microsoft® Office application or custom application you develop.
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.
Show:
© 2014 Microsoft