
Tips.Net > WordTips Home > Formatting > Character Formatting > Changing Character Color
Summary: Need to easily change the color of some selected text? A quick way to do it is with a custom macro that sets just the hue that you want. This tip describes such a macro and explains how to modify it for any color desired. (This tip works with Microsoft Word 97, Word 2000, Word 2002, and Word 2003.)
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 |
Tip #253 applies to Microsoft Word versions: 97 2000 2002 2003
Take Control! Master the real power behind Word! Successfully master the secrets of powerful formatting and create documents that stand out from the rest. Best of all, you can create documents that are easy to maintain and quick to change.
Check out WordTips: Sytles and Templates today!
Discover how to use Word's mail merge tool to create your own custom documents in just minutes. Great e-book answers all your questions. (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips