Disable Method

Microsoft Word Visual Basic

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.

expression.Disable

expression    Required. An expression that returns a KeyBinding object.

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."

Dim kbLoop As KeyBinding

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