KeyBindings.Key Method
Word Developer Reference |
Returns a KeyBinding object that represents the specified custom key combination.
Syntax
expression.Key(KeyCode, KeyCode2)
expression A variable that represents a KeyBindings collection.
Parameters
Name | Required/Optional | Data Type | Description |
---|---|---|---|
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. |
Return Value
KeyBinding
Remarks
If the key combination doesn't exist, this method returns Nothing.
You can use the BuildKeyCode method to create the KeyCode or KeyCode2 argument.
Example
This example assigns the ALT+F4 key combination to the Arial font and then displays the number of items in the KeyBindings collection. The example then clears the key combinations (returns it to its default setting) and redisplays the number of items in the KeyBindings collection.
Visual Basic for Applications |
---|
|
This example assigns the CTRL+SHIFT+U key combination to the macro named "Macro1" in the active document. The example uses the Key property to return a KeyBinding object so that Word can retrieve and display the command name.
Visual Basic for Applications |
---|
|
This example determines whether the CTRL+SHIFT+A key combination is part of the KeyBindings collection.
Visual Basic for Applications |
---|
|
See Also