Syntax
ToolsCustomizeMenus [.MenuType = number] [, .Position = number] [, .Category = number] [, .Name = text] [, .Menu = text] [, .AddBelow = text] [, .MenuText = text] [, .Rename] [, .Add] [, .Remove] [, .ResetAll] [, .CommandValue = text] [, .Context = number]
Remarks
Changes menu assignments for built-in commands, macros, fonts, AutoText entries, and styles. The arguments for the ToolsCustomizeMenus statement correspond to the options on the Menus tab in the Customize dialog box (Tools menu).
Argument | Explanation |
.MenuType | The type of menu you want to modify: 0 or omitted Menus on the menu bar when a document is open 1 Menus on the menu bar when no document is open 2 Shortcut menus |
.Position | The position on the menu where you want to add or remove an item: –1 or omitted Automatically determines an appropriate position for adding the item. –2 Adds the item to the bottom of the menu. n Adds, removes, or renames the item at the specified position, where 1 is the first position, 2 is the second position, and so on. When adding an item, if n is greater than the number of existing menu items plus one, the item is added to the bottom of the menu. Note that separators are considered items and that in some cases, a set of menu items is counted as one. For more information, see CountMenuItems(). |
.Category | The type of item to be assigned: 1 or omitted Built-in commands 2 Macros 3 Fonts 4 AutoText entries 5 Styles |
Argument | Explanation |
.Name | The name of the built-in command, macro, font, AutoText entry, or style whose menu assignment you want to change. When adding or removing a separator, specify "(Separator)." |
.Menu | The menu you want to change. Menu names are listed in the Change What Menu list box. Including an ampersand (&) before the access key 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. |
.AddBelow | The text of or command name associated with the menu item after which you want to add the new item. Note that you do not need to specify this argument if you specify .Position. If you specify both arguments, .AddBelow takes precedence. |
.MenuText | The text as it will appear on the menu. Place an ampersand (&) in front of the access key, if any. On the Macintosh, access keys are displayed only in menu mode, which is activated by pressing the DECIMAL (.) key on the numeric keypad (Num Lock off). If you want an ampersand to appear in the menu text, include two ampersands. For example, setting .MenuText to "&Examples && Practices" creates the menu item "Examples & Practices." |
.Rename | Renames the menu item specified by .Menu and .Name (and .Position, if specified), with the text specified by .MenuText. |
.Add | Adds the item to the menu. |
.Remove | Removes the item from the menu. |
.ResetAll | Resets all menu assignments to their defaults. Note that this argument resets changes made with ToolsCustomizeMenuBar as well as ToolsCustomizeMenus. |
.CommandValue | Additional text required for the command specified by .Name, if any. For example, if .Name is set to Color, .CommandValue specifies the color. For more information, see the next table in this entry. |
.Context | Determines where the new menu assignment is stored: 0 (zero) or omitted Normal template 1 Active template |
When removing or renaming menu items, you must specify .Name and .Menu. Word starts at the bottom of the specified menu and moves up until it finds an item that performs the action specified by .Name. You can also specify .Position and .MenuText if you need to be sure that the menu item you are changing is at a specific position and has specific menu text. Note that if Word can't find an item that matches each of the specified criteria, an error occurs.
The following table lists in the left column commands that require a command value and describes in the right column how to specify .CommandValue. The equivalent action in the Customize dialog box (Tools menu) to specifying .CommandValue is selecting an item in the list box that appears when you select one of the following commands in the Commands box.
If .Name is set to | .CommandValue must be | |
Borders, Color, or Shading | A number — specified as text — corresponding to the position of the setting in the list box containing values, where 0 (zero) is the first item, 1 is the second item, and so on. | |
Columns | A number between 1 and 45 — specified as text — corresponding to the number of columns you want to apply. | |
Condensed | A text measurement between 0.1 pt and 12.75 pt specified in 0.05-point increments (72 points = 1 inch). | |
Expanded | A text measurement between 0.1 pt and 12.75 pt specified in 0.05-point increments (72 points = 1 inch). | |
FileOpenFile | The path and filename of the file to open. If the path is not specified, the current folder is assumed. | |
Font Size | A positive text measurement, specified in 0.5-point increments (72 points = 1 inch). | |
Lowered, Raised | A text measurement between 1 pt and 64 pt specified in 0.5-point increments (72 points = 1 inch). | |
Symbol | A string created by concatenating a Chr$() instruction and the name of a symbol font (for example, Chr$(167) + "Symbol"). |
Example
This example adds the macro TestMacro to the Help menu. The menu item for this macro is Test, which appears immediately after Index. Because .AddBelow is specified, .Position is not required.
ToolsCustomizeMenus .Category = 2, .Name = "TestMacro", \ .MenuType = 0, .Menu = "Help", .MenuText = "&Test", \ .AddBelow = "Index", .Context = 0, .Add
See Also
CountMenuItems(), MenuItemMacro$(), MenuText$(), ToolsCustomizeMenuBar