KeyBindings Property

Returns a KeyBindings collection that represents customized key assignments, which include a key code, a key category, and a command.


expression Required. An expression that returns one of the objects in the Applies To list.


This example assigns the CTRL+ALT+W key combination to the FileClose command. This keyboard customization is saved in the Normal template.

CustomizationContext = NormalTemplate
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyAlt, _
    wdKeyW), KeyCategory:=wdKeyCategoryCommand, _

This example inserts the command name and key combination string for each item in the KeyBindings collection.

Dim kbLoop As KeyBinding

CustomizationContext = NormalTemplate
For Each kbLoop In KeyBindings
    Selection.InsertAfter kbLoop.Command & vbTab _
        & kbLoop.KeyString & vbCr
    Selection.Collapse Direction:=wdCollapseEnd
Next kbLoop

Applies to | Application Object | Global Object

See Also | Add Method | BuildKeyCode Method | Command Property | CustomizationContext Property | ListCommands Method