Changing Character Color

by Allen Wyatt
(last updated July 14, 2016)

5

Imagine that you are developing a document that uses text colors to signal special meanings to the reader. For instance, you may use red text to indicate what the user should type. If you are developing a document in which you use color within your text, it can be a real bother to use the menus over and over again to change text colors. In such an instance, it is helpful to have a macro that modifies the color automatically. You can assign the macro to a key combination or a toolbar button so you don't have to use the menus. The following macro changes the color of the currently selected text to red.

Sub MakeRed()
    If Selection.Type = wdSelectionNormal Or _
      Selection.Type = wdSelectionBlock Then
        Selection.Font.ColorIndex = wdRed
    Else
        Beep
    End If
End Sub

If you want to use a different color besides red, change the color assignment made in the macro. (Just change the constant wdRed to the desired color.) VBA allows you to use constants to represent colors. There are seventeen different color numbers available:

Number Text Color Word Constant
0 Auto wdAuto
1 Black wdBlack
2 Blue wdBlue
3 Cyan wdTurquoise
4 Green wdBrightGreen
5 Magenta wdPink
6 Red wdRed
7 Yellow wdYellow
8 White wdWhite
9 Dark Blue wdDarkBlue
10 Dark Cyan wdTeal
11 Dark Green wdGreen
12 Dark Magenta wdViolet
13 Dark Red wdDarkRed
14 Dark Yellow wdDarkYellow
15 Dark Gray wdGray50
16 Light Gray wdGray25

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (253) applies to Microsoft Word 97, 2000, 2002, and 2003.

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

Averaging the Last Numbers in a Column

Need to calculate a running average for the last twelve values in a constantly changing range of values? The formula ...

Discover More

Changing the Footnote Continuation Notice

When a footnote needs to span two printed pages, Word prints a continuation notice at the end of the footnote being ...

Discover More

Using Only Odd Page Numbers

Do you need to number the pages of your document using only odd page numbers? Word doesn't provide a way to do this, but you ...

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 (MENU)

Missing Fonts in a Letterhead

When you create a document (such as a letterhead) that you want multiple people to use, you need to be concerned with whether ...

Discover More

Making Text Bold

Want a cool shortcut to make your text bold? Here's a method that fits in wonderfully with how things are done in the online ...

Discover More

Protecting Hidden Text

Formatting some of your text as hidden can be a great help when you need to keep some things from being viewed or printed. ...

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 for this tip:

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. 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 one more than 2?

2016-01-06 16:42:09

Brian Henderson

I want to know how to program and run macros in Word. Is there anything out there that shows me how to do that?


2015-12-04 06:50:40

Stanley Gooch

The macro for Changing Character Color is very helpful but demonstrating my lack of knowledge, how would you modify it so that having changed the underlined text to red it then changes back to standard black for the following text?


2015-07-15 04:55:27

Khaled

I have a table, i want to color a background cell with a red color without highlighting the contents just when positioning the cursor in the cell.

Thanks


2015-07-01 03:51:58

Des Lavender

Thanks for this. I tried to record a macro but no code appeared. Frustrating. Oh, and I don't like the way you can no linger customise the button image.


2014-11-27 01:02:38

Anish

This helped. Thanks!


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.

Links and Sharing
Share