From: WordTips Gold [mailto:awyatt@dcomp.com]
Sent: Wednesday, May 22, 2002 5:43 PM
To: sathyamurthy@netkracker.com
Subject: WordTips Gold (HTML) for 22 May 2002 [Changing Character Color]
22 May 2002 | Copyright 2002 by DCI |
For Over 750 Tips and Articles About Word, Subscribe to WordTips Online Solutions The Information You Need, When You Need It |
Welcome to your daily helping of WordTips Gold!
Teaching you how to be more productive with Microsoft Word!
Changing Character Color
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 VBA 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 third line of the macro. 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 |
This tip applies to Word 97, Word 2000, and Word 2002. |
Publisher and Copyright Information
WordTips Gold is published by Discovery Computing Inc. WordTips and WordTips Gold are trademarks of Discovery Computing Inc. WordTips Gold is a member of the Vital News newsletter family.
Copyright © 2002 by Discovery Computing Inc., All Rights Reserved. You may manually forward this issue to your friends or store it for your own use, but any other broadcast, publication, retransmission, copying or storage is strictly prohibited.
Subscription Information
Subscriptions to WordTips Gold are free. For information on subscribing to WordTips Gold, visit the Web site at http://www.VitalNews.com/wordtips/gold.htm.
The information in WordTips Gold is just a small sample of the full-range of information available at WordTips Online Answers. Subscriptions to WordTips Online Answers are different than subscriptions to WordTips Gold. For information on subscribing to WordTips Online Answers, visit the Web site at http://wtonline.VitalNews.com.
You are currently subscribed to wordtipsgoldh as: sathyamurthy@netkracker.com
To unsubscribe send a blank e-mail to leave-wordtipsgoldh-12504367J@list.netatlantic.com
No comments:
Post a Comment