Article ID: 182299
Article Last Modified on 11/23/2006
Sub AddTest1()
MenuBars(xlWorksheet).Menus("View").MenuItems.Add _
Caption:="Test", Before:="Toolbars..."
End Sub
Sub AddTest2()
'Test whether you use Microsoft Excel 5.0.
If Val(Application.Version) < 8 Then
'Set the value of the variable equal to the correct menu
'command name for Microsoft Excel 5.0.
xBefore = "Toolbars..."
'Otherwise, assume you use Microsoft Excel 98 (version 8.0).
ElseIf Val(Application.Version) = 8 Then
'Set the value of the variable equal to the correct menu
'command name for Microsoft Excel 98.
xBefore = "Toolbars"
End If
'Add the new command. The command works correctly because the
'menu command name in the Before argument (the variable xBefore)
'is correct.
MenuBars(xlWorksheet).Menus("View").MenuItems.Add _
Caption:="Test", Before:=xBefore
End Sub
MenuBars(xlWorksheet).Menus("View").MenuItems.Add Caption:="Test", _
Before:="Toolbars..."
This line of code adds a new menu command, Test, above the "Toolbars..."
menu command on the View menu.
MenuBars(xlWorksheet).Menus("View").MenuItems("Toolbars...").Delete
In each of the lines of code, the menu command "Toolbars..." is referred by
its exact name. In Microsoft Excel 98 Macintosh Edition, the names of some
menu commands are changed. The new names may cause problems if macro code
refers to these menu items by name.
Microsoft Excel 5.0 Microsoft Excel 98
Menu menu command menu command
--------------------------------------------------------------
View Toolbars... Toolbars
Insert Chart Chart...
Insert Note... Comment
Data PivotTable... PivotTable Report...
sheet tab Rename... Rename
shortcut
menu*
* This menu is the xlWorkbookTab shortcut menu.Additional query words: XL98
Keywords: kbdtacode kberrmsg kbprb KB182299