KeysBoundTo Property

Applies To

Application object, Global object.

Description

Returns a KeysBoundTo object that represents all the key combinations assigned to the specified item. Read-only.

Syntax

expression.KeysBoundTo(KeyCategory, Command, CommandParameter)

expression Optional. An expression that returns an Application object.

KeyCategory Required Long. The category of the key combination. Can be one of the following WdKeyCategory constants: wdKeyCategoryAutoText, wdKeyCategoryCommand, wdKeyCategoryFont, wdKeyCategoryMacro, wdKeyCategoryStyle, or wdKeyCategorySymbol.

Command Required String. The name of the command.

CommandParameter Optional Variant. Additional text, if any, required for the command specified by Command. For more information, see the "Remarks" section in Add method (KeyBindings object).

See Also

BuildKeyCode method, Context property, CustomizationContext property, FindKey property.

Example

This example displays all the key combinations assigned to the FileOpen command in the template attached to the active document.

CustomizationContext = ActiveDocument.AttachedTemplate
For Each myKey In KeysBoundTo(KeyCategory:=wdKeyCategoryCommand, _
        Command:="FileOpen")
    myStr = myStr & myKey.KeyString & vbCr
Next myKey
MsgBox myStr
This example removes all key assignments from Macro1 in the Normal template.

CustomizationContext = NormalTemplate
For Each aKey In KeysBoundTo(KeyCategory:=wdKeyCategoryMacro, _
        Command:="Macro1")
    aKey.Disable
Next aKey