The KeyBinding Object

The following list describes some of the properties and methods of a KeyBinding object:

The Clear method

Removes the key binding from the KeyBindings collection and also resets a built-in command to its default key assignment. The syntax is:

KeyBinding.Clear

The ClearAll method of the KeyBindings collection can be used to clear all custom key bindings and reset the default key bindings.

The Command property

This read-only property returns the command assigned to the specified key combination as a string. A list of the more than 1,000 commands is available from the Customize menu item (under the Tools menu). Those commands whose names are followed by a colon require a command parameter. In addition to the well-known Word commands such as New, Open, Print, Bold, and Italic, there are a great many commands that most Word users have never encountered, such as Auto Correct Exceptions, Bookshelf Lookup Reference, Control Run, and so on.

The CommandParameter property

This read-only property returns a string containing the command parameter for the key binding. If the command in question takes no parameters, this property returns an empty string.

For instance, the FileOpenFile command (which opens a specific file) requires a string parameter that specifies the filename (and path) for the file to open. The Symbol command requires a string of the form:

Chr(x) & FontName

where x is a character code and FontName is the name of a symbol font, as in:

Chr(125) & " Symbol"

For more ...

Get Writing Word Macros, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.