Class ColorFormat (Word VBA)

The class ColorFormat represents the color of a one-color object or the foreground or background color of an object with a gradient or patterned fill. You can set colors to an explicit red-green-blue value by using the RGB property.

Set

To use a ColorFormat class variable it first needs to be instantiated, for example

Dim cft as ColorFormat
Set cft = Selection.Font.TextColor

The following procedures can be used to set variables of type ColorFormat: FillFormat.BackColor, FillFormat.ForeColor, Font.TextColor, GlowFormat.Color, LineFormat.BackColor, LineFormat.ForeColor, ShadowFormat.ForeColor, ThreeDFormat.ContourColor and ThreeDFormat.ExtrusionColor

Brightness

Returns a Single that represents the brightness of a specified shape color.

You can enter a number from -1 (darkest) to 1 (lightest) for the Brightness property, 0 (zero) being neutral.

Sub NewTintedShape() 
 Dim shpHeart As Shape 
 
 Set shpHeart = ActiveDocument.Shapes _ 
 .AddShape(Type:=msoShapeHeart, Left:=150, _ 
 Top:=150, Width:=250, Height:=250) 
 With shpHeart.Fill.ForeColor 
 .RGB = RGB(Red:=255, Green:=28, Blue:=0) 
 .Brightness = 0.4 
 End With 
End Sub

ObjectThemeColor

Returns or sets a WdThemeColorIndex constant that represents the theme color for a color format.

Possible Values are wdNotThemeColor - No color, wdThemeColorAccent1 - Accent color 1, wdThemeColorAccent2 - Accent color 2, wdThemeColorAccent3 - Accent color 3, wdThemeColorAccent4 - Accent color 4, wdThemeColorAccent5 - Accent color 5, wdThemeColorAccent6 - Accent color 6, wdThemeColorBackground1 - Background color 1, wdThemeColorBackground2 - Background color 2, wdThemeColorHyperlink - Hyperlink color, wdThemeColorHyperlinkFollowed - Followed hyperlink color, wdThemeColorMainDark1 - Dark main color 1, wdThemeColorMainDark2 - Dark main color 2, wdThemeColorMainLight1 - Light main color 1, wdThemeColorMainLight2 - Light main color 2, wdThemeColorText1 - Text color 1, wdThemeColorText2 - Text color 2.
Selection.Font.TextColor.ObjectThemeColor = wdNotThemeColor

Parent

Returns an object that represents the parent object of the specified ColorFormat object.

Dim objParent As Object
Set objParent = Selection.Font.TextColor.Parent

RGB

Returns or sets the red-green-blue (RGB) value of the specified color.

ActiveDocument.Shapes(2).Fill.ForeColor.RGB = RGB(128, 128, 128)

TintAndShade

Returns a Single that represents the lightening or darkening of a specified shape's color.

You can enter a number from -1 (darkest) to 1 (lightest) for the TintAndShade property, 0 (zero) being neutral.

Sub NewTintedShape() 
 Dim shpHeart As Shape 
 Set shpHeart = ActiveDocument.Shapes _ 
 .AddShape(Type:=msoShapeHeart, Left:=150, _ 
 Top:=150, Width:=250, Height:=250) 
 With shpHeart.Fill.ForeColor 
 .RGB = RGB(Red:=255, Green:=28, Blue:=0) 
 .TintAndShade = 0.3 
 End With 
End Sub

Type

Returns or sets the shape color type.

Dim mctType As Office.MsoColorType
mctType = Selection.Font.TextColor.Type