Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Changes the command assigned to the specified key binding.
Syntax
expression. Rebind
( _KeyCategory_
, _Command_
, _CommandParameter_
)
expression Required. A variable that represents a 'KeyBinding' object.
Parameters
Name | Required/Optional | Data type | Description |
---|---|---|---|
KeyCategory | Required | WdKeyCategory | The key category of the specified key binding. |
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. |
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
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.