KeyBindings Collection Object

Multiple objects
KeyBindings
KeyBinding

A collection of KeyBinding objects that represent the custom key assignments in the current context. Custom key assignments are made in the Customize Keyboard dialog box.

Using the KeyBindings Collection

Use the KeyBindings property to return the KeyBindings collection. The following example inserts after the selection the command name and key combination for each item in the KeyBindings collection.

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

Use the Add method to add a KeyBinding object to the KeyBindings collection. The following example adds the CTRL+ALT+H key combination to the Heading 1 style in the active document.

CustomizationContext = ActiveDocument
KeyBindings.Add KeyCategory:=wdKeyCategoryStyle, _
    Command:="Heading 1", _
    KeyCode:=BuildKeyCode(wdKeyControl, wdKeyAlt, wdKeyH)

Use KeyBindings(index), where index is the index number, to return a single KeyBinding object. The following example displays the command associated with the first KeyBinding object in the KeyBindings collection.

MsgBox KeyBindings(1).Command

Properties | Application Property | Context Property | Count Property | Creator Property | Parent Property

Methods | Add Method | ClearAll Method | Item Method | Key Method

Parent Objects | Application | Global

Child Objects

See Also | KeysBoundTo Collection Object