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.

WdKeyCategory

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

Applies to | KeyBinding Object

See Also | CustomizationContext Property | Disable Method | FindKey Property | KeysBoundTo Property