KeysBoundTo Property
Returns a KeysBoundTo object that represents all the key combinations assigned to the specified item.
expression.KeysBoundTo(KeyCategory, Command, CommandParameter)
expression Optional. An expression that returns one of the objects in the Applies To list.
KeyCategory Required WdKeyCategory. The category of the key combination.
WdKeyCategory can be one of these WdKeyCategory constants. |
wdKeyCategoryAutoText |
wdKeyCategoryCommand |
wdKeyCategoryDisable |
wdKeyCategoryFont |
wdKeyCategoryMacro |
wdKeyCategoryNil |
wdKeyCategoryPrefix |
wdKeyCategoryStyle |
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 the Add method for the KeyBindings object.
Example
This example displays all the key combinations assigned to the FileOpen command in the template attached to the active document.
Dim kbLoop As KeyBinding
Dim strOutput As String
CustomizationContext = ActiveDocument.AttachedTemplate
For Each kbLoop In _
KeysBoundTo(KeyCategory:=wdKeyCategoryCommand, _
Command:="FileOpen")
strOutput = strOutput & kbLoop.KeyString & vbCr
Next kbLoop
MsgBox strOutput
This example removes all key assignments from Macro1 in the Normal template.
Dim aKey As KeyBinding
CustomizationContext = NormalTemplate
For Each aKey In _
KeysBoundTo(KeyCategory:=wdKeyCategoryMacro, _
Command:="Macro1")
aKey.Disable
Next aKey