Assigning a Macro to a Shortcut Key

by Allen Wyatt
(last updated April 26, 2016)

15

Word allows you to assign macros or commands to specific key combinations. These key combinations are referred to as shortcut keys, and when used they result in the macro or command being executed. When you first create a macro by recording it, Word gives you the opportunity to assign the macro to a specific key combination. If you later want to change the key combination, you can follow these steps:

  1. Display the Word Options dialog box. (In Word 2007 click the Office button and then click Word Options. In Word 2010 and Word 2013 display the File tab of the ribbon and then click Options.)
  2. At the left side of the dialog box click Customize (Word 2007) or Customize Ribbon (Word 2010 and Word 2013).
  3. Near the bottom of the dialog box click the Customize button. Word displays the Customize Keyboard dialog box. (See Figure 1.)
  4. Figure 1. The Customize Keyboard dialog box.

  5. Scroll through the Categories list and select the Macros category. The list at the right side of the dialog box changes to show the currently available macros.
  6. In the Macros list, select the macro you want assigned to the shortcut key.
  7. With the insertion point in the Press New Shortcut Key box, press the shortcut key you want to use. For instance, if you want to use Ctrl+Alt+J, press that.
  8. Just below the Current Keys box you can see whether the shortcut key is already assigned to a different function.
  9. Click on Assign.
  10. Repeat steps 5 through 8 for each change you want to make.
  11. Click on Close.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (8058) applies to Microsoft Word 2007, 2010, and 2013.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Formatting Footnote Reference Marks

The reference marks that appear for footnotes in a document are normally just superscripted digits. If you want to change the ...

Discover More

Forcing the Date to the Next Wednesday

Working with today's date in Word is easy. Trying to manipulate dates to come up with a future one can be an entirely ...

Discover More

Continuous Formatting for Footnotes

If you've got a lot of short footnotes in a document, you might be looking for a way to save space by "crunching up" the ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More WordTips (ribbon)

Modifying Behavior of the Open Dialog Box

The Open dialog box is one that few of us think about, but you can control how it behaves with a little bit of macro coding. ...

Discover More

Calculated Dates

Word makes it easy to insert today's date in a document, but not as easy to insert a date X number of days in the future. ...

Discover More

Printing Shortcut Key Assignments from a Macro

Need to know what shortcut keys are defined? You can use a single macro command line to print out the definitions.

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 9 - 2?

2017-05-12 09:37:26

Tami

We have shortcut keys on word templates (developed in 2003). I have one template where the shortcut key will not work, how do I restore it???


2017-03-30 02:50:48

Alan Elston

I originally found the Ctrl and Ctrl + Shift quite restrictive, until I realised that you actually have an infinite amount of possibilities..
_1st ) Ctrl + Shift + Alt + letter/Fkey
Ctrl + Shift + Alt + letter
and
Ctrl + Shift + Alt + Fkey

_2nd ) Number Sequences. This I find particularly useful for similar macros..
Ctrl + Shift + B ( take fingers away , then ) a number

_...
Remember that you do not type anything in the dialogue box.. you use the actual short cut key you want to use and it then appears and it appears then in the “Press new shortcut Key:” bar
It is worth experimenting with the many key combinations available


2017-03-29 16:14:53

Hernan

Many thanks!


2016-11-17 09:15:22

Alan Elston

Thanks for this very clear Blog

I think a small Typo at 7. – it should read “..Just to the left of....”

It might be worth emphasising at 6. That you must use the actual Key Ctrl and a letter or the Keys Ctrl and Alt and a letter. You cannot type in a string such as “Ctrl+Alt+B”. You also cannot paste in a string of a valid combination.

Alan


2016-08-26 22:56:04

Harold

@Steve: You can use the VBA object document.tables(1).cell(1,2) to reference the range content of cell row 1 column 2. As an example referred to your macro:
aaa=activedocument.tables(1).cell(1,1)
replacement text:
aab=activedocument.tables(1).cell(1,2)

Maybe a better way would be to use autotext for the acronyms rather than a table? Then whenever someone types an acronym it will automatically be translated to the correct text.


2016-08-26 03:43:20

shivaraj dalawai

Thank you so much for your working solution.


2016-08-23 12:37:46

steve whittle

I have an acronym list that I find useful in many docs that I write. It is simply two columns wide containing the acronym in the first column and its meaning in the second column. Also, each acronym is hyperlinked to its own bookmark and I have leveraged the hyperlink screen tip.

The reason for this is so I can run a (hard coded) macro to globally scan and replace plain text words matching the hyperlinked acronyms above. The essence of this macro is below as an example - where AAA is the first acronym, BBB the second and so on all the way down to ZZZ (there are approx. 80 acronyms in the table).

My 2 questions are:

1) What code do I need to simply use the cell content found in the first cell, propagate that then move down to the second, propagate that etc. so that I am not using hard coded values?
2) What code do I need to efficiently loop through each acronym _ vs. replicating the code over and over again as per below.

Many thanks for any help you can provide.



Sub Replace_text_with_links
'Ensure cursor is positioned properly at top of table, first column to the immediate right of first word
Selection.GoTo What:=wdGoToBookmark, Name:="Start"
'Ensuring user wants to proceed
If MsgBox("To start this brief global word 'mouse over' replacement routine, press 'Yes' to start. Otherwise,
press 'No' to exit.", vbYesNo) <> vbYes Then
Exit Sub
End If
'************************************************************
'AAA
Selection.MoveLeft Unit:=wdWord, Count:=l, Extend:=wdExtend
Selection.Copy
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection. Find
.Text = "AAA"
.Replacement.Text = "Ic"
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAIiWordForms = False
End With

Selection.Find.Execute Replace:=wdReplaceAIi
'************************************************************
'BBB
Selection.MoveDown Unit:=wdLine, Count:=l
Selection.MoveLeft Unit:=wdWord, Count:=l, Extend:=wdExtend
Selection.Copy
Selection.Find.ClearFormatting
Selection. Find. Replacement.Clea rFormatting
With Selection.Find
.Text = "BBB"
.Replacement.Text = "Ic"
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAIIWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAII
'************************************************************
'zzz
Selection.MoveDown Unit:=wdLine, Count:=l
Selection. Move Left Unit:=wdWord, Count:=l, Extend:=wdExtend
Selection.Copy
Selection. Find .Clea rFormatting
Selection. Find. Replacement.ClearFormatting
With Selection. Find
.Text = "zzz"
.Replacement.Text = "Ic"
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAIIWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAIi
'************************************************************
End Sub


2016-08-15 14:29:48

bob baxter

how can I assign an F key to insert my email address and another F key to insert my password?


2016-02-08 03:51:02

Hiren

Thank you very much!! very well explained didn't face difficulty to follow the post.


2015-12-07 12:38:20

Caren

Will be receiving a macro to insert a specified logo into my Word and Excel document. Have my ribbons customized, so how do I implement these macros for my word and excel programs. Last time someone deleted my customized ribbon.


2015-10-03 14:54:07

Harold

There are a few issues related to this:
1) You need to store the key assignment in the normal.dotm template as said before.
If fact, I think the best practice would be to store the key assignment in the template where the macro resides.

2) If your macros are in the same template (Normal.dotm), they have to be in the NEWMACROS module. There seems to be a bug in Word when assigning keys to macros that are in a different module (within the same template). Word assumes that they are in the Newmacros Module when they are not.
To get an indication of this: Customize keyboard dialog - enter one of the keys you have defined in the "Press new shortcut key" box. If the text shows up below the current keys box that "Currently assigned to ...", the key is correctly assigned.

[I haven't tested this with other templates than Normal.dotm yet].

3) If you get the message at the end that Word cannot save your Normal.Dotm file, you probably have an issue with another instance of Word being open and locking this file. I have seen this with Excel and embedded word documents where Word has been started under the DCOM process. Sometime this process will still linger after Excel has been closed.
My method is: Open Word before you open Excel with that embedded document.


2015-09-20 12:09:19

Stephen McBride

Does not store the macro key. Need to write a new macro using record keystrokes that run my macro to get it to go to a key.


2015-09-02 18:56:27

DellaMac

Excellent!!! I am overwhelmed with Macros and I am always looking for new and easier ways to work with them. Love this, just love it. Thanks for the help and keep it coming.


2014-08-01 19:21:38

Emm

You need to select "globaltemplate" instead of "this document" when saving the macro


2013-12-07 05:11:54

Judy

I follow all of the steps for creating a macro as above but Word does not save it. I have to create the macro every day. Any ideas?

Thanks.


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.