Add Method (KeyBindings Collection)

See Also         Example         Applies To

Adds a new KeyBinding object to the KeyBindings collection. A KeyBinding object represents a custom key assignment, which includes a key code, a key category, and a command.

Syntax

expression.Add(KeyCategory, Command, KeyCode, KeyCode2, CommandParameter)

expression   Required. An expression that returns a KeyBindings object.

KeyCategory   Required Long. The category of the key assignment. Can be one of the following WdKeyCategory constants:

wdKeyCategoryAutoText

wdKeyCategoryCommand

wdKeyCategoryDisable

wdKeyCategoryFont

wdKeyCategoryMacro

wdKeyCategoryNil

wdKeyCategoryPrefix

wdKeyCategoryStyle

wdKeyCategorySymbol


Command   Required String. The command that the specified key combination executes.

KeyCode   Required Long. A key you specify by using one of the WdKey constants.

KeyCode2   Optional Variant. A second key you specify by using one of the WdKey constants.

CommandParameter   Optional Variant. Additional text, if any, required for the command specified by Command. For details, see the "Remarks" section.

Remarks

You can use the BuildKeyCode method to create the KeyCode or KeyCode2 argument.

In the following table, the left-hand column contains commands that require a command value, and the right-hand column describes what you must do to specify CommandParameter for each of these commands. (The equivalent action in the Customize Keyboard dialog box (Tools menu) to specifying CommandParameter is selecting an item in the list box that appears when you select one of the following commands in the Commands box.)

If Command is set to CommandParameter must be
Borders, Color, or Shading A number — specified as text — corresponding to the position of the setting selected in the list box that contains 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 point and 12.75 points specified in 0.05-point increments (72 points = 1 inch)
Expanded A text measurement between 0.1 point and 12.75 points specified in 0.05-point increments (72 points = 1 inch)
FileOpenFile The path and file name of the file to be opened. If the path isn't specified, the current folder is used.
Font Size A positive text measurement, specified in 0.5-point increments (72 points = 1 inch)
Lowered, Raised A text measurement between 1 point and 64 points, 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")