Shortcuts to Change Text Colors

Written by Allen Wyatt (last updated August 19, 2017)
This tip applies to Word 2007, 2010, 2013, and 2016


6

As an editor, Gillian likes to color-code sections of text for authors. She would, therefore, like to be able to create multiple keyboard shortcuts to highlight in different colors once she has selected text (e.g., Alt+G for green, Alt+B for blue, and Alt+Y for yellow). Gillian wonders if this is possible.

Yes, it is possible, but you'll need to use a macro to do the work. Before doing so, however, you'll need to figure out what shortcut keys you want to use. Gillian suggests using Alt+G, Alt+B, and Alt+Y. You can do this, but it may conflict with other uses of the Alt key (like accessing the ribbon tools from the keyboard). It may be better to use shortcut keys such as Shift+Alt+G, Shift+Alt+G, and Shift+Alt+Y.

To record a macro that sets text colors, just follow these steps:

  1. Select a word or phrase. (It doesn't really matter what you select.)
  2. Display the Developer tab of the ribbon.
  3. In the Code group, click the Record Macro tool. Word displays the Record Macro dialog box. (See Figure 1.)
  4. Figure 1. The Record Macro dialog box.

  5. In the Name field, enter a macro name that is descriptive of what you are doing. (For instance, if you are recording a macro to make text blue, you could use the name MakeTextBlue.)
  6. Using the Store Macro In drop-down list, choose All Documents (Normal.dotm).
  7. Click the Keyboard button. Word closes the Record Macro dialog box and shortly displays the Customize Keyboard dialog box. Note that the macro name you supplied in step 4 is shown in the dialog box and the insertion point is blinking in the Press New Shortcut Key box. (See Figure 2.)
  8. Figure 2. The Customize Keyboard dialog box.

  9. Press the shortcut key you want used to invoke the macro. (For instance, you might press Shift+Alt+B since your macro will make the selected text blue.)
  10. Click the Assign button. The shortcut key is now shown as assigned to the macro.
  11. Click Close. Word closes the Customize Keyboard dialog box and the macro recorder is running.
  12. Press Ctrl+D. Word displays the Font dialog box. (See Figure 3.)
  13. Figure 3. The Font dialog box.

  14. Using the Font Color drop-down list, pick whatever color of blue you want.
  15. Click OK to close the Font dialog box.
  16. Click the Stop Recording tool in the Code group.

At this point your macro is complete, and you can invoke it by selecting text and then pressing Shift+Alt+B. You can create similar macros to set your other colors, as desired.

There is one part of the above steps that needs to be explained. Note the way the Font dialog box is displayed in steps 10 through 12. You might think you can simply display the Home tab of the ribbon and use the tools located there to set the font color. The problem is that, in test, this didn't always result in the step (setting the color) being recorded by the macro recorder. The font on the screen changed color, but the step didn't show up in the macro. The only way to reliably set the font color and have it recorded in the macro was to display the Font dialog box, as noted.

If you were to examine the macro you just recorded, you would see that it looks like this:

Sub MakeTextBlue()
'
' MakeTextBlue Macro
'
'
    With Selection.Font
        .Name = "+Body"
        .Size = 11
        .Bold = False
        .Italic = False
        .Underline = wdUnderlineNone
        .UnderlineColor = wdColorAutomatic
        .StrikeThrough = False
        .DoubleStrikeThrough = False
        .Outline = False
        .Emboss = False
        .Shadow = False
        .Hidden = False
        .SmallCaps = False
        .AllCaps = False
        .Color = 12611584
        .Engrave = False
        .Superscript = False
        .Subscript = False
        .Spacing = 0
        .Scaling = 100
        .Position = 0
        .Kerning = 0
        .Animation = wdAnimationNone
        .Ligatures = wdLigaturesNone
        .NumberSpacing = wdNumberSpacingDefault
        .NumberForm = wdNumberFormDefault
        .StylisticSet = wdStylisticSetDefault
        .ContextualAlternates = 0
    End With
End Sub

If you think this is a long macro for a single step (setting the text color), you'd be right. It is a classic example of the macro recorder being overly comprehensive in what it records. You could easily pare down the macro to the following:

Sub MakeTextBlue()
    Selection.Font.Color = 12611584
End Sub

If you wanted even a bit more flexibility in the macro, you could also use the following:

Sub MakeTextBlue()
    Selection.Font.Color = RGB(0, 0, 255)
End Sub

You can then easily adjust the RGB value used for the color by playing with the three parameters used with the RGB function.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

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

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

Using the Organizer to Manage Macros

There may come a time when you want to copy or rename macros. You can do this quite easily by using the Organizer tool ...

Discover More

Alt+Enter Stopped Working Correctly

What do you do if a keypress you know worked correctly before all of a sudden stops working as you expect? This tip ...

Discover More

Splitting Information into Rows

Got too much information in a single cell? Here's how you can use a macro to pull apart that information and put it into ...

Discover More

Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!

More WordTips (ribbon)

Quickly Increasing Point Size

Want to adjust the size of a text selection? Here's a quick shortcut to increase the size.

Discover More

Underlining Quoted Text

Do you have a document in which you need to convert all the quoted text (text surrounded by quotes) to underlined text? ...

Discover More

Finding Missing Fonts

When you open documents that were created a long time ago on a system far, far away (sounds almost epic, doesn't it?), ...

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}] (all 7 characters, in the sequence shown) 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 8 - 5?

2022-03-06 13:11:36

Kathy E

I want to express my thanks to Mr. Allen Wyatt for this very useful article; it have saved me lots of time and keystrokes for many different things as the recording of Macros in WORD was explained so perfectly. I have recorded several Macro following the instruction here and they have all been used extensively. Thank you.


2020-05-29 15:56:10

JM

I use Ctrl+Z a lot in writing protocols to undo a string of previous changes, but I discovered that if the above macro is used to change the color of a word and using Ctrl+Z later to undo changes, it will get stuck at the point where the font was changed. In other words, all changes before use of the macro cannot be undone. Is there a way around this?


2019-06-07 10:25:20

Andrew

Bhavin, the process would be quite similar, except the colors of the highlighting are limited to certain built-in colors. The macro would be something like this:

Sub HighlightTextBlue()
Selection.Range.HighlightColorIndex = wdBlue
End Sub

The permitted colors are:

wdBlack
wdBlue
wdBrightGreen
wdDarkRed
wdDarkYellow
wdGray25
wdGray50
wdGreen
wdNoHighlight
wdPink
wdRed
wdTeal
wdTurquoise
wdViolet
wdWhite
wdYellow


2019-06-06 22:38:27

Bhavin Dalal

This is an excellent article. I really loved it. I have one question. Is it possible to similarly create Short cut to highlight the selected words with specific color instead of changing color of text?
Thanking you in anticipation.


2017-11-13 16:17:08

Jonathan

Massively helfpul! Very rarely comment on this sort of thing but couldn't find anything else out there that helped me do this! Thank you!!


2017-08-22 07:48:33

Gillian

Thank you very much!


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.

Videos
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.