Disable Method

Applies To

KeyBinding object.

Description

Removes the specified key combination if it's currently assigned to a command. After you use this method, the key combination has no effect. Using this method is the equivalent to clicking the Remove button in the Customize Keyboard dialog box (Tools menu).

Note Use the Clear method with a KeyBinding object to reset a built-in command to its default key assignment. You don't need to remove or rebind a KeyBinding object before adding it elsewhere.

Syntax

expression.Disable

expression Required. An expression that returns a KeyBinding object.

See Also

Clear method, CustomizationContext property, Execute method, Rebind method.

Example

This example removes the CTRL+SHIFT+B key assignment. This key combination is assigned to the Bold command by default.

CustomizationContext = NormalTemplate
FindKey(BuildKeyCode(wdKeyControl, wdKeyShift, wdKeyB)).Disable
This example assigns the CTRL+SHIFT+O key combination to the Organizer command. The example then uses the Disable method to remove the CTRL+SHIFT+O key combination and displays a message.

CustomizationContext = NormalTemplate
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyO, wdKeyControl, wdKeyShift), _
    KeyCategory:=wdKeyCategoryCommand, Command:="Organizer"
With FindKey(BuildKeyCode(wdKeyO, wdKeyControl, wdKeyShift))
    MsgBox .Command & " is assigned to CTRL+Shift+O"
    .Disable
    If .Command = "" Then MsgBox "Nothing is assigned to CTRL+Shift+O"
End With
This example removes all key assignments for the global macro named "Macro1."

CustomizationContext = NormalTemplate
For Each aKey In KeysBoundTo(KeyCategory:=wdKeyCategoryMacro, _
        Command:="Macro1")
    aKey.Disable
Next aKey