MenuItemText$()

Syntax

MenuItemText$(Menu$, Type, Item [Context])

Remarks

Returns the menu text associated with a macro or built-in command assigned to the specified menu. You can change the menu text with ToolsCustomizeMenus.

Note

The menu text for a subset of built-in commands changes depending on the current conditions of the Word environment. For these commands, MenuItemText$() returns the command name instead of the menu text. The commands include EditCopy, EditPaste, EditRedoOrRepeat, EditUndo, FileClose, FileCloseAll, FileCloseOrCloseAll, FileExit, FileQuit, FileSave, FileSaveAll, FileSaveAs, FormatFrameOrFramePicture, TableDeleteGeneral, TableInsertGeneral, TableSort, TableToOrFromText, and ToolsProtectUnprotectDocument.

Argument

Explanation

Menu$

The name of a menu or shortcut menu. Menu names are listed in the Change What Menu box on the Menus tab in the Customize dialog box (Tools menu).

Including an ampersand (&) before the underlined letter in the menu name is optional (for example, you can specify either "File" or "&File"). Do not include the parenthetical phrases "(No Document)" and "(Shortcut)", even though that text appears in the Customize dialog box.

Type

The type of menu:

0 (zero) Menus on the menu bar when a document is open

1 Menus on the menu bar when no document is open

2 Shortcut menus

Item

A number representing the item's position on the menu. The number can range from 1 to the number returned by CountMenuItems(). Separators between commands are considered items, and if Item represents the position of a separator, MenuItemText$() returns the string "(Separator)."

Note that lists such as the list of recently used files on the File menu or proofing tools on the Tools menu correspond to a single item. If you specify the position of a list, MenuItemText$() returns a parenthetical phrase describing the list — for example, "(List of Recently Used Files") or "(List of Proofing Tools)".


Argument

Explanation

Context

Specifies the menu assignments for which you want to return the menu text:

0 (zero) or omitted The assignments that are available when a document based on the Normal template is active

1 The assignments that are currently available

Note that the assignments that are available depend on the custom settings, if any, of the active template, any loaded global templates, and the Normal template.


Example

This example displays a message box with the menu text of the first Word-related item on the Help menu when no document is open (on the Macintosh, this is the first item after the Show Balloons command):


MsgBox MenuItemText$("Help", 1, 1, 0)

See Also

CountMenuItems(), CountMenus(), MenuItemMacro$(), MenuText$(), ToolsCustomizeMenus