If you have any problems with this web page, please first read my browser notesbrowser notes [link to ../../Miscellany/Browsers/Browsers.php] and if you still have issues, feel free to e-mail mee-mail me [link to e-mail the author at mailto:Tony@WordArticles.com]

Colours in 2003 and earlier


Colours in Word 2003 and earlier

The User Interface

Since Word 2000, with a couple of exceptions, if one wanted to change the colour of an element of a document, one would, one way or another, arrive first at a simple dialog that looked something like this:

The Word 2003 Font Color Pop-up
The Word 2003 Font Color Pop-up

The dialog contained a fixed palette of 40 of the most commonly used colours — all that really made them most commonly used, of course, was the fact that they were in the default dialog — along with, as seen in the example above, the option of having an automatic colour, a Windows system colour that (usually) contrasted with the background.

If a different colour was wanted, the dialog had a “More Colors…” choice, which, if selected, led to an expanded dialog showing what I believe is called a colour wheel:

The Word 2003 Expanded Colors Dialog
The Word 2003 Expanded Colors Dialog

This expanded dialog had, again, a fixed palette, including all but Dark Blue of the 40 colours in the basic palette with 88 further colours and a separate block of black, white, and 15 intermediate shades of grey. If still finer tuning of colours was required, however, the dialog had a second tab:

The Word 2003 Custom Colors Dialog
The Word 2003 Custom Colors Dialog

From this tab any combination of red, green, and blue could be used to select a precise colour. The “Color model” dropdown also allowed selecting colours using the HSL (Hue, Saturation, Luminosity) colour model.

As well as the colour selection itself, a transparency value could be set to control how visible the document content behind the coloured object could be. Word 2000 had a simple checkbox for semi transparency (although any percentage value could be set in VBA) and, in Word 2002 the transparency slider, as shown in the figures above, was introduced.

The Exceptions

Ignoring embedded MS Graph objects, which had a colour model based on the 56-colour palette used by Excel, there were (and still are) two exceptions to the standard set of dialogues.

The first exception was Highlighting. Once upon a time, highlighting was available in only four colours: bright yellow, green, blue, and pink, colours corresponding to the highlighter pens available in all offices. By Word 2000 the range had extended to 16 colours (one of which, white, was not available in the UI), and there it has stayed.

The Word 2003 Highlight Dropdown from the Formatting Toolbar
The Word 2003 Highlight Dropdown from the Formatting Toolbar

The second exception was Reviewing. Although almost every version of Word has included changes to the options available here, the colour choices did not change from Word 2000 to Word 2003. In Word 2003, there were 16 colours (the same 16 as available for highlighting), as well as Auto and By Author options to choose from.

The Word 2003 Reviewing / Track Changes Options Dialog
The Word 2003 Reviewing / Track Changes Options Dialog


ColorFormat Objects

From an Object Model / VBA perspective there were two types of object when it came to colouring: those (drawing objects) that had ColorFormat Objects and those (other colourable elements: fonts, borders, etc.) that didn't.

It's possible you've never heard of ColorFormat objects as they masquerade behind other names and, if that's the case, you can probably count yourself lucky. They are returned by, for example, the ForeColor and BackColor properties of various objects but are rarely used stand-alone, normally only being referenced for their RGB property, of which a little more in a moment.

Ever since being introduced in Office 97, ColorFormat objects appeared to have the potential to be more than they were, but I was never able to make any use of the methods and properties they advertised, nor was I able to discover any significant information about them. They had a hidden SchemeColor property, an index into a colour scheme that could, supposedly, be applied to the object. In 2002 they gained a TintAndShade property which allowed them to be made darker or lighter from code (but only in limited circumstances via the UI), a feature that only really made sense when used with reference to an externally-defined colour (as in a colour scheme, perhaps). In 2002 they also gained Cyan, Magenta, Yellow, and Black properties, and a SetCMYK method; again, none of these ever appeared usable.

Somewhat bizarrely, ColorFormat objects in Excel were similar, but not exactly the same, and appeared to work a little bit better, although there was no mechanism I knew to change the rather odd built-in default colour scheme. Equally bizarrely, there was a separate ColorFormat hidden class in the Office library, which seemed even less usable than the Word one.

For most practical purposes in Word one could, one was almost obliged to, assume that the Type of ColorFormat objects was set to msoColorTypeRGB and treat the RGB property as though it were a Color property like any other.

Color Properties

Document elements that did not have ColorFormat objects had simple Color properties, normally, but not exclusively, set to RGB values. There were enumeration constants for some 50 or so colours and any other colour could be specified explicitly by using its red, green and blue components. There was never a need to understand anything about how the values were held by Word, but if one happened to know the appropriate numeric values, they could be used directly. The following four statements (not an exhaustive list) all do the same thing: set the colour of the Selection to red.

Selection.Font.Color = wdColorRed
Selection.Font.Color = RGB(255, 0, 0)
Selection.Font.Color = 255
Selection.Font.Color = &HFF

The non-RGB color values that could, in certain circumstances, be used all had special enumeration constants so that, again, it was not necessary to know any details of the internal workings of Word in order to be able to work with them. The constants were:

One RGB value had special meaning in VBA: red 127, green 150, blue 152, a nondescript shade of grey equating to the decimal number 9999999. It was returned as a font colour when the range being queried was not all in the same colour. When applied to a font from VBA it didn't take. A different, and non-contentious, value of -1 (0xFFFFFFFF) was returned as a colour from queries of other elements (for example, borders) when the range included multiple colours.

There were, and remain, various oddities. For example, trying to set a font colour to red 126, green 150, blue 152 (decimal 9999998) from VBA resulted in a “Bad parameter” error message. Setting Table Borders from VBA over a mixed Range also seemed to have no effect, or, on occasion, the wrong effect. I have no doubt there were others.

ColorIndex Properties

ColorIndex properties are really a hangover from a long-gone version of Word but, although wounded, they won't lie down. They are numbers, from 1 to 16, referring to the limited range of colours that were once all that Word could use. They are not in any way related to the actual colours they indicate and have been arbitrarily assigned; a ColorIndex value of 6, for example, refers to ‘pure’ red, one of 7 to ‘pure’ yellow.

Word still uses ColorIndex values for Highlighting, and for the various Change Tracking colour settings, features that are still restricted to just 16 colours. Word also maintains ColorIndex values for many other colourable items; Word, itself, does not really use these but they can be set and queried.

If you set the ColorIndex for the font of some text, say, to a value of 6, the text would duly turn red and the Color of the font would be set to the RGB value for red (red 255, green 0, blue 0). Conversely if you set the Color of the text to the RGB value for red, then its ColorIndex value would be set to 6. Where it got more interesting was when you set the RGB value of the text to one which did not correspond to a specific ColorIndex value. I don't know the algorithm used but Word converted the RGB value, somehow, reasonably well, to the ColorIndex value for the nearest colour.

As with colours, there were some special ColorIndex values, in particular zero for no special ColorIndex when, for example, the colour of text was set to Automatic, which isn't a specific colour and, thus, cannot have a specific index.

Again, as with colours, there were special values meaning that the elements being queried did not all have the same ColorIndex. For font colours this value was the same decimal 9999999 as returned for Color but for other elements a value of 65535 (0xFFFF) was returned.

Really Old Colours

Long, long, ago there was a set of 16 arbitrarily assigned numbers (0 to 15) representing the 16 colours that computers, and early versions of the Basic language, could work with. These colours were different from the ColorIndex colours, and where the same colour was in both sets, different codes had been assigned. I have never seen these codes used anywhere in Word but there is a VBA Function, QBColor to translate them into RGB codes and no article on colour would be complete without at least giving it a mention.