MenuItemMacro$()

Syntax

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

Remarks

Returns the name of the macro or built-in command associated with the specified menu item.

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.


Argument

Explanation

Type

The type of menu:

0 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, MenuItemMacro$() 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, MenuItemMacro$() returns an empty string ("").

Context

Specifies the menu assignment for which you want to return the macro or command name:

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

1 The assignment that is currently available

Note that the assignment that is available depends on the custom settings, if any, of the active template, any loaded global templates, and the Normal template.


Example

This example defines an array variable containing the names of commands and macros assigned to the File menu in the current working environment. To define
a similar array for the File menu of the active template, substitute CountMenuItems("File", 0, 1) in the first instruction and MenuItemMacro$("File", 0, count, 1) in the fourth instruction.


numItems = CountMenuItems("File", 0, 0)
Dim fileItem$(numItems - 1)
For count = 1 To numItems
    fileItem$(count - 1) = MenuItemMacro$("File", 0, count, 0)
Next count

See Also

CountMacros(), KeyMacro$(), MacroDesc$(), MacroName$(), MenuItemText$(), ToolsCustomizeMenus