Rebind Method
Applies To
KeyBinding object.
Description
Changes the command assigned to the specified key binding.
Syntax
expression.Rebind(KeyCategory, Command, CommandParameter)
expression Required. An expression that returns a KeyBinding object.
KeyCategory Required Long. The key category of the specified key binding. Can be one of the WdKeyCategory constants:
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.
See Also
CustomizationContext property, Disable method, FindKey property, KeysBoundTo property.
Example
This example reassigns the CTRL+SHIFT+S key binding to the FileSaveAs command.
CustomizationContext = NormalTemplate
Set myKey = FindKey(BuildKeyCode(wdKeyControl, wdKeyShift, wdKeyS))
myKey.Rebind KeyCategory:=wdKeyCategoryCommand, Command:="FileSaveAs"
This example rebinds all keys assigned to the macro named "Macro1" to the macro named "ReportMacro."
CustomizationContext = ActiveDocument.AttachedTemplate
For Each myKey In KeysBoundTo(KeyCategory:=wdKeyCategoryMacro, _
Command:="Macro1")
myKey.Rebind KeyCategory:=wdKeyCategoryMacro, Command:="ReportMacro"
Next myKey