Using Command Bars

See Also         Specifics

In general, to create or modify toolbars, menu bars, and shortcut menus that you want to deliver with your Visual Basic application, you should use the customization features of the container application. Changes made to toolbars, menu bars, and shortcut menus using the features of the container application are known as "design-time" changes. For information about using the container application to make design-time changes, see the online Help for that application.

You can add and modify toolbars, menu bars, and shortcut menus (and their component parts) by using the CommandBars portion of the Microsoft Office object model in Visual Basic code. You can write code that runs once to create toolbars and menu bars; in effect, the code simulates making design-time changes. In some container applications, however, you may be required to use a combination of this kind of Visual Basic code and the customization interface to design your Visual Basic application. The following are some common areas where you must use a combination of code and the container application's interface:

You can also write code that exists in your Visual Basic application to make changes to toolbars and menu bars while your application is running (for example, you can write code to disable a command on a menu bar under certain conditions, or to add buttons to a toolbar in response to a user's actions). Changes brought about by your code while your Visual Basic application is running are known as "run-time" changes.

The following topics provide information about how you can make design-time and run-time changes to toolbars and menu bars from your Visual Basic code.

Adding and Modifying Toolbars

Adding and Managing Menu Bars and Menu Items

Adding and Displaying Shortcut Menus