Article ID: 160520
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 or 7.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 and 7.0.
xBefore = "Toolbars..."
'Otherwise, assume you use Microsoft Excel 97 (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 97.
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 97, 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, 7.0 Microsoft Excel 97 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: XL97
Keywords: kbdtacode kberrmsg kbprb KB160520