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. To use a ColorFormat class variable it first needs to be instantiated, for example
Dim cft as ColorFormat
Set cft = Selection.Font.TextColor
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. Here you can find possible values for
Selection.Font.TextColor.ObjectThemeColor = wdNotThemeColor
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