O'Reilly logo

Writing Word Macros, Second Edition by Steven Roman PhD

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required