Organizing Your Keyboard Shortcuts in Microsoft Word

Words
184
Reading
1 min
Listen
Play
9y

In the previous post, I described how you can define keyboard shortcuts from VBA in Microsoft Word. As I said, this is a powerful technique that can boost your productivity greatly. Now, consider this situation. What if you want to have multiple sets of shortcuts that can be switched easily? For example, you may have a set of shortcuts for working with drawing objects, another set for working with text, etc. The whole point is that if you can switch whole sets of shortcuts, you can reassign familiar key combinations to other actions.

This can be easily done. For each set of shortcuts, create a macro that defines the shortcut keys and a macro that clears those shortcuts. That's all it takes to have multiple sets of easily interchangeable shortcut sets.

Here is an example:

    Sub DefineSet1()
        KeyBindings.Add KeyCategory:=wdKeyCategoryCommand, Command:="ViewWeb", KeyCode:=BuildKeyCode(wdKeyW, wdKeyAlt, wdKeyControl)
        KeyBindings.Add KeyCategory:=wdKeyCategoryMacro, Command:="MyMacro", KeyCode:=BuildKeyCode(wdKeyS, wdKeyAlt, wdKeyShift)
        KeyBindings.Add KeyCategory:=wdKeyCategoryStyle, Command:="MyStyle", KeyCode:=BuildKeyCode(wdKeyC, wdKeyAlt, wdKeyControl, wdKeyShift)
        KeyBindings.Add KeyCategory:=wdKeyCategorySymbol, Command:=" " & ChrW(Val("&H2011")), KeyCode:=BuildKeyCode(wdKeyHyphen, wdKeyAlt, wdKeyControl, wdKeyShift)
    End Sub
    Sub ClearSet1()
        FindKey(BuildKeyCode(wdKeyW, wdKeyAlt, wdKeyControl)).Clear
        FindKey(BuildKeyCode(wdKeyS, wdKeyAlt, wdKeyShift)).Clear
        FindKey(BuildKeyCode(wdKeyC, wdKeyAlt, wdKeyControl, wdKeyShift)).Clear
        FindKey(BuildKeyCode(wdKeyHyphen, wdKeyAlt, wdKeyControl, wdKeyShift)).Clear
    End Sub

For each set of shortcut keys, you must create one macro for assigning the key combinations and one macro for clearing them. By running the respective macros, you can easily switch between multiple sets of shortcut keys.


Related Posts

Organizing Your Keyboard Shortcuts in Microsoft Word | Ecency