Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

XL2000: Menu Added in Wrong Position on Menu Bar


View products that this article applies to.

This article was previously published under Q213569

↑ Back to the top


Symptoms

When you run a Visual Basic for Applications macro that adds a new menu to a menu bar, the new menu appears to the right of the Help menu, rather than to the left of it.

↑ Back to the top


Cause

This behavior occurs because, in Microsoft Excel 2000, the Help menu does not have any special status. In versions of Microsoft Excel earlier than Excel 97, you cannot create new menus to the right of the Help menu.

↑ Back to the top


Workaround

If you need to create a custom menu to the left of the Help menu, add the "Before:=" argument to the line of code that creates the new menu, for example:
MenuBars(xlWorksheet).Menus.Add Caption:="Custom", Before:="Help"
				
You can use any valid menu name in the Before argument. The new menu will appear to the left of the specified menu name.

↑ Back to the top


More information

In versions of Excel earlier than Excel 97, if you use a macro to create a custom menu and do not specify the menu bar position where the new menu should appear, the new menu always appears to the left of the Help menu. For example, if you execute this line of Visual Basic macro code
MenuBars(xlWorksheet).Menus.Add Caption:="Custom"
				
the new Custom menu will appear to the left of the Help menu.

This behavior occurs because the Help menu has special status in earlier versions of Microsoft Excel: the Help menu is always the rightmost menu on a menu bar.

In Microsoft Excel 2000, the Help menu has no special status. Because of this, Excel always adds new menus to the right of the Help menu.

If your custom menu needs to appear to the left of the Help menu, use the workaround shown earlier in this article to create the custom menu.

↑ Back to the top


Keywords: KB213569, kbprogramming, kbprb, kbdtacode

↑ Back to the top

Article Info
Article ID : 213569
Revision : 5
Created on : 10/10/2006
Published on : 10/10/2006
Exists online : False
Views : 220