Color Property

Microsoft Word Visual Basic

Show All

Color Property

       

Returns or sets the 24-bit color for the specified Border or Font object. Can be any valid WdColor constant or a value returned by Visual Basic's RGB function.

WdColor can be one of these WdColor constants.
wdColorGray625
wdColorGray70
wdColorGray80
wdColorGray875
wdColorGray95
wdColorIndigo
wdColorLightBlue
wdColorLightOrange
wdColorLightYellow
wdColorOliveGreen
wdColorPaleBlue
wdColorPlum
wdColorRed
wdColorRose
wdColorSeaGreen
wdColorSkyBlue
wdColorTan
wdColorTeal
wdColorTurquoise
wdColorViolet
wdColorWhite
wdColorYellow
wdColorAqua
wdColorAutomatic
wdColorBlack
wdColorBlue
wdColorBlueGray
wdColorBrightGreen
wdColorBrown
wdColorDarkBlue
wdColorDarkGreen
wdColorDarkRed
wdColorDarkTeal
wdColorDarkYellow
wdColorGold
wdColorGray05
wdColorGray10
wdColorGray125
wdColorGray15
wdColorGray20
wdColorGray25
wdColorGray30
wdColorGray35
wdColorGray375
wdColorGray40
wdColorGray45
wdColorGray50
wdColorGray55
wdColorGray60
wdColorGray65
wdColorGray75
wdColorGray85
wdColorGray90
wdColorGreen
wdColorLavender
wdColorLightGreen
wdColorLightTurquoise
wdColorLime
wdColorOrange
wdColorPink

expression.Color

expression   Required. An expression that returns one of the objects in the Applies To list.

Example

This example changes the color of the text in the first paragraph of the active document to green.

ActiveDocument.Paragraphs(1).Range.Font.Color = wdColorGreen

This example changes the color of the selected text to dark red.

Selection.Font.Color = wdColorDarkRed

This example adds a dotted indigo border around each cell in the first table.

If ActiveDocument.Tables.Count >= 1 Then
    For Each aBorder In ActiveDocument.Tables(1).Borders
        aBorder.Color = wdColorIndigo
        aBorder.LineStyle = wdLineStyleDashDot
        aBorder.LineWidth = wdLineWidth075pt
    Next aBorder
End If