WD: WordBasic CharColor DefinedLast reviewed: February 2, 1998Article ID: Q89853 |
The information in this article applies to:
SUMMARYThe Microsoft WordBasic CharColor statement sets the character color of the selection to the color specified in the Color argument. The CharColor() function returns the color of the selected text. For more information about setting or retrieving font color values for Word 97 for Windows or Word 98 Macintosh Edition, while in the Visual Basic for Applications Editor click the Office Assistant, type "ColorIndex," click Search, and then click to view "ColorIndex Property."
MORE INFORMATIONWARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
CharColor SyntaxCharColor <Color> The color argument is a numeric code for one of the following character colors supported in Word 2.0 and 6.0 for Windows:
Color Code Color Name ---------- ---------- 0 Auto (color specified by the Control Panel setting) 1 Black 2 Blue 3 Cyan 4 Green 5 Magenta 6 Red 7 Yellow 8 White 9 Dark Blue 10 Dark Cyan 11 Dark Green 12 Dark Magenta 13 Dark Red 14 Dark Yellow 15 Dark Gray 16 Light GrayThe function form of CharColor returns the same number codes set by the CharColor statement or the value -1 if all the selected text is not the same color. Below is an example of the function form of CharColor:
Sub MAIN n = CharColor() If n = - 1 Then Print "More than one color is used in the selection" End SubThe following macro inserts the word "Color" formatted for each of the 16 colors available using the CharColor command in Word version 2.0 and 6.0 for Windows:
Sub MAIN For count = 1 To 16 Insert "Color" WordLeft 1, 1 CharColor count CharRight InsertPara Next End SubThe CharColor command under Word for Windows versions 1.x supports eight character colors, as outlined below:
Color Code Color Name ---------- ----------- 0 Auto (color specified by the Control Panel setting) 1 Black 2 Blue 3 Cyan 4 Green 5 Magenta 6 Red 7 Yellow 8 WhiteThe following sample macro inserts the word "Color" formatted for each of the 8 colors available using the CharColor command in Word for Windows versions 1.x:
Sub MAIN For count = 0 To 8 Insert "Color" WordLeft 1, 1 CharColor count CharRight InsertPara Next End Sub REFERENCES"Using WordBasic," by WexTech Systems and Microsoft, pages 159-160 "Microsoft Word for Windows and OS/2 Technical Reference," pages 137-138
|
Additional query words: charcolor character color
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |