Class KeyBinding (Word VBA)
The class KeyBinding represents a custom key assignment in the current context. The KeyBinding object is a member of the KeyBindings collection.
Class Application gives access to class KeyBinding.
Dim kbg as KeyBinding
Set kbg = Dim lngKeyCode As Long: lngKeyCode =
FindKey(KeyCode:=lngKeyCode)
For Each
Here is an example of processing the KeyBinding items in a collection.
Dim lngCode As Long
Dim kbg As KeyBinding
CustomizationContext = NormalTemplate
lngCode = BuildKeyCode(wdKeyAlt, wdKeyControl, wdKeyW)
For Each kbg In KeyBindings
If lngCode = kbg.KeyCode Then MsgBox kbg.KeyString & " is already in use"
Next kbg
Methods
Clear - Removes the specified key binding from the KeyBindings collection and resets a built-in command to its default key assignment.
Disable - Removes the specified key combination if it is currently assigned to a command. After you use this method, the key combination has no effect.
Execute - Runs the command associated with the specified key combination.
Rebind - Changes the command assigned to the specified key binding.
Properties
Command returns the command assigned to the specified key combination.
CommandParameter returns the command parameter assigned to the specified shortcut key.
Context returns an Object that represents the storage location of the specified key binding.
KeyCategory returns the type of item assigned to the specified key binding.
KeyCode returns a unique number for the first key in the specified key binding.
KeyCode2 returns a unique number for the second key in the specified key binding.
KeyString returns the key combination string for the specified keys (for example, CTRL+SHIFT+A).
Protected true if you cannot change the specified key binding in the Customize Keyboard dialog box.
Related Classes
Document - Represents a document. The Document object is a member of the Documents collection. The Documents collection contains all the Document objects that are currently open in Word.