XL98: Worksheet Menu Bar May Not Appear As Expected

ID: Q184897

The information in this article applies to:

SYMPTOMS

After you run a Microsoft Visual Basic for Applications macro to create a floating toolbar, only the Apple and Help menus appear on the menu bar.

CAUSE

This problem occurs when you attempt to replace the worksheet menu bar with a custom floating menu bar. To see an example of this behavior, please see the "More Information" section in this article.

WORKAROUND

Microsoft 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 the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/

You may be able to work around this problem by changing the MenuBar argument of the Add method to False instead of True. The following sample macro creates a new toolbar but does not replace the menu bar:

   Sub Add_Toolbar()

   ' The following line of code creates a floating toolbar that does not
   ' replace the menu bar.
   ' This is specified by the MenuBar argument, which in the code below,
   ' is set to False.

   Application.CommandBars.Add "newbar", msoBarFloating, False, True

   ' Display the CommandBar.

   CommandBars("newbar").Visible = True

   End Sub

STATUS

This is by design in Microsoft Excel 98 Macintosh Edition.

MORE INFORMATION

On the Macintosh, the menu bar must remain at the top of the screen. Therefore, a macro ignores the floating argument and replaces the worksheet menu bar when you run a macro that contains code to create a floating menu bar.

Example

To see an example of this behavior, follow these steps:

1. Start Microsoft Excel 98 with a new workbook.

2. Press OPTION+F11 to start the Visual Basic Editor.

3. On the Insert menu, click Module.

4. In the new module type the following:

      Sub Test_menubar()

      Application.CommandBars.Add "newbar", msoBarFloating, True, True
      CommandBars("newbar").Visible = True

      End Sub

      Sub Reset_Menubar()

      Application.CommandBars("Worksheet Menu Bar").Visible = True

      End Sub

5. Press OPTION+F11 to return to Excel.

6. Press OPTION+F8.

7. Select the Test_menubar macro, and then click Run.

   Note that the menu bar contains only the Apple and Help menus.

To reset the menu bar, follow these steps:

1. Press OPTION+F8.

2. Select the Reset_Menubar macro. Click Run

   The original menu bar reappears.

REFERENCES

For more information about CommandBars, from the Visual Basic Editor, click the Office Assistant, type "CommandBars Collection," click Search, and then click to view "CommandBars Collection Object."

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If the Assistant is not able to answer your query, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q176476
   TITLE     : OFF: Office Assistant Not Answering Visual Basic Questions

Additional query words: XL98 OFF98 WD98 PPT98
Keywords          : kbprg kbdta kbdtacode xlui xltoolbar xlmac 
Version           : MACINTOSH:98
Platform          : MACINTOSH
Issue type        : kbprb

Last Reviewed: May 18, 1999