Organizing Your Keyboard Shortcuts in Microsoft Word

in vba •  7 years ago 

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

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

It is considered as a "helpful post for the community". Keep posting.

Nice post. Useful also

@ghasemkiani you realy done an awesome work on the two sides by utilizing Steemit Forum. in one hand you shared instructive related articles for extraordinarily understudies and in the other hand you bolstered everybody who comment on your blog, that is realy appreciable. your past and this post are extremely useful for "Keyboard Shortcuts in Microsoft Word" an excessive amount of learnt from you. Much obliged.

This is very useful as we all need the help of shortcut.
Thanks for sharing this post.

Hey @ghasemkiani, This is my very first comment on any of your posts. I randomly landed here and after reading this post, I feel happy that I did. Though we are living in modern times where we can solve the problems with a single click yet modern life is not simple but complicated. So, the technique that you mentioned is a smart way to save time.

Thank You. Keep sharing the smart posts. Stay awesome man.

Steem On!

Helpful. Lemme just get to it.

"Nice post share sir & you always give our helpful post & thanx you so much for sharing . #resteem & upvote done .

good article
I hope everyone will be benefited

i likes in your post dear

well done sir

sorry for late . now i watch this post dear. alredy resteemed this post @ghasemkiani

Helpful post.

This post has received a 10.55 % upvote from @buildawhale thanks to: @ghasemkiani. Send at least 1 SBD to @buildawhale with a post link in the memo field for a portion of the next vote.

To support our daily curation initiative, please vote on my owner, @themarkymark, as a Steem Witness

very useful post sharing dear @ghasemkiani for Microsoft-word user . thanx you . this post #resteem & upvote done .

Wow, very very useful techniques dear @ghasemkiani. This is like a magic using macros. Thanks dear. Keep Sharing!

nice post. shared :)

you always have the best content ghasemkiani keep it up!