XL97: Menu Added in Wrong Position on Menu Bar

Last reviewed: February 27, 1998
Article ID: Q158072
The information in this article applies to:
  • Microsoft Excel 97 for Windows

SYMPTOMS

In Microsoft Excel 97, 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.

CAUSE

This will occur because, in Microsoft Excel 97, the Help menu does not have any special status. In earlier versions of Microsoft Excel, new menus cannot be created to the right of the Help menu.

WORKAROUND

If you need a custom menu to be created 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 be created to the left of the specified menu name.

STATUS

This behavior is by design of Microsoft Excel 97.

MORE INFORMATION

In earlier versions of Microsoft Excel, 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 occurs because the Help menu has special status in earlier versions of Microsoft Excel: the Help menu is always the right-most menu on a menu bar.

In Microsoft Excel 97, the Help menu has no special status. Because of this, new menus are added 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.


Additional query words: XL97 8.00 commandbar command bar
Keywords : kbcode kbprg xlvbahowto xlvbainfo xl97vbmigrate
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbprb


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 27, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.