February 26, 2014

Assigning a Word Macro to a Shortcut Key

Filed under: Main — Tags: , — admin @ 12:01 am

Welcome to Weird Word Wednesday here at the Wambooli Wamblog. Last week’s post was about creating a macro, which is fun and useful. It becomes even more funner and usefuller when you assign the macro to a keyboard shortcut.

You can assign a shortcut key to a macro when you create the macro or you can add a shortcut key later. Obviously it’s easier to assign the shortcut key when you create the macro.

As an example, the following steps create the Word_Swap macro. It swaps two words, for example, changing this that to that this. These steps assign that macro to the Alt+Shift+S keyboard shortcut:

1. Click the Record Macro button on the Developer tab.
2. Type Word_Swap as the macro name.
3. Choose the current document, Document1 (or whatever), from the Store Macro In menu.
4. Click the Keyboard button.

The Customize Keyboard dialog box shows up, similar to what you see in Figure 1. You have two jobs to complete in this dialog box. First, assign the shortcut key and second ensure that the shortcut is saved for the current document only.

Figure 1. Assign a keyboard shortcut to the macro here.

Figure 1. Assign a keyboard shortcut to the macro here.

Yes, if you were creating a macro for all your documents — a global macro — you’d save it in the Normal template, but this exercise is merely for practice.

5. In the Customize Keyboard dialog box, choose Document1 from the Save Changes In menu, as shown in Figure 1.
6. Click the mouse in the Press New Shortcut Key box.
7. On the keyboard, press Alt+Shift+S.

As you can see on your screen and in Figure 1, the keyboard shortcut Alt+Shift+S is currently unassigned. If it were assigned, the command it’s assigned to would show up in the dialog box. In that case, you’d have to choose another keyboard shortcut. I strongly recommend that you don’t overwrite Word’s keyboard shortcuts unless you really, really know what you’re doing.

8. Click the Assign button.

You see that the keyboard shortcut Alt+Shift+S appears in the Current Keys list. That’s exactly what you want.

9. Click the Close button to dismiss the Customize Keyboard dialog box.

You’re now recording the Word_Swap macro.

10. Press Shift+Ctrl+→ to select the current word.
11. Press Ctrl+X to cut that word.
12. Press Ctrl+→ to move one word right.
13. Press Ctrl+V to paste the cut word.

The words are swapped.

If these steps are too complex for you, please review last Wednesday’s blog post.

14. Click the Stop Recording button on the Ribbon.

The Word_Swap macro has been recorded and saved. It’s instantly ready for use:

Press Alt+Shift+S to swap the next two words.

Yep, you just created your own Word command by using a Macro. It’s assigned to the Alt+Shift+S keyboard shortcut and it’s saved only in the current document, which you can keep or discard. Next week I’ll discuss creating a toolbar button for a macro instead of assigning a keyboard shortcut.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.


Powered by WordPress