Rebind Method
Changes the command assigned to the specified key binding.
expression.Rebind(KeyCategory, Command, CommandParameter)
expression Required. An expression that returns a KeyBinding object.
KeyCategory Required WdKeyCategory. The key category of the specified key binding.
WdKeyCategory can be one of these WdKeyCategory constants. |
wdKeyCategoryAutoText |
wdKeyCategoryCommand |
wdKeyCategoryDisable |
wdKeyCategoryFont |
wdKeyCategoryMacro |
wdKeyCategoryNil |
wdKeyCategoryPrefix |
wdKeyCategoryStyle |
wdKeyCategorySymbol |
Command Required String. The name of the specified command.
CommandParameter Optional Variant. Additional text, if any, required for the command specified by Command. For information about values for this argument, see the Add method for the KeyBindings object.
Example
This example reassigns the CTRL+SHIFT+S key binding to the FileSaveAs command.
Dim kbTemp As KeyBinding
CustomizationContext = NormalTemplate
Set kbTemp = _
FindKey(BuildKeyCode(wdKeyControl, wdKeyShift, wdKeyS))
kbTemp.Rebind KeyCategory:=wdKeyCategoryCommand, _
Command:="FileSaveAs"
This example rebinds all keys assigned to the macro named "Macro1" to the macro named "ReportMacro."
Dim kbLoop As KeyBinding
CustomizationContext = ActiveDocument.AttachedTemplate
For Each kbLoop In _
KeysBoundTo(KeyCategory:=wdKeyCategoryMacro, _
Command:="Macro1")
kbLoop.Rebind KeyCategory:=wdKeyCategoryMacro, _
Command:="ReportMacro"
Next kbLoop