Article ID: 159619 - Last Review: November 23, 2006 - Revision: 2.4 XL97: Sample Macros for Customizing Menus and SubmenusThis article was previously published under Q159619 On This PageSUMMARY
The process of programmatically changing menus in Microsoft Excel 97 is
different than earlier versions of Microsoft Excel. The biggest change in
Microsoft Excel 97 is that toolbars, menu bars, and shortcut menus are
considered one type of object (called a command bar). Most Visual Basic for
Applications macros that you create in earlier versions of Microsoft Excel
that customize menus and toolbars work in Microsoft Excel 97. However, some
macros may fail. In this case, modify the macro code to work with the new
object type.
This article provides several examples that illustrate how to customize menu bars, menus, and toolbars in Microsoft Excel 97. NOTE: Many of the sample macros in this article use the ID number for a particular control as an argument for the Add method. You must know the ID number if you want to restore built-in menus that you deleted. For additional information, please see the following article in the Microsoft Knowledge Base: 159466
(http://support.microsoft.com/kb/159466/EN-US/
)
XL97: List of ID Numbers for Built-In Command Bar Controls
MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites: Microsoft Certified Partners - https://partner.microsoft.com/global/30000104 (https://partner.microsoft.com/global/30000104) Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice (http://support.microsoft.com/gp/advisoryservice) For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS (http://support.microsoft.com/default.aspx?scid=fh;en-us;cntactms) Deleting an Entire Menu BarThe following macro disables the Worksheet menu bar. After you run the following macro, the Worksheet menu bar is not displayed when a worksheet is active.Deleting and Restoring a Menu on a Menu BarThe following macro deletes the Help menu from the Worksheet menu bar.Deleting and Restoring a Menu Command on a MenuThe following macro deletes the Contents And Index menu command on the Help menu.Deleting and Restoring a Submenu on a MenuThe following macro deletes the "Microsoft on the Web" submenu on the Help menu.Deleting and Restoring a Menu Command on a SubmenuThe following macro deletes the Protect Sheet menu command on the Protection submenu (on the Tools menu).Deleting and Restoring a Menu on a ToolbarThe following macro deletes the Draw menu on the Drawing toolbar.Deleting and Restoring a Menu Item on a Shortcut MenuThe following macro deletes the Insert Comment menu command on the worksheet cell shortcut menu.REFERENCES
For more information about programmatically customizing command bars, click
Microsoft Visual Basic Help on the Help menu in the Visual Basic Editor,
type "Customizing menus," click Search, and then click "Overview of Command
Bars" to go to the topic.
| Article Translations
|

Back to the top
