Class ColorFormat (Excel VBA)

The class ColorFormat represents the color of a one-color object, the foreground or background color of an object with a gradient or patterned fill, or the pointer color. To use a ColorFormat class variable it first needs to be instantiated, for example

Brightness

Returns or sets the luminosity of the specified object.

The value for this property must be a number from 0.0 (dimmest) to 1.0 (brightest).


ActiveSheet.Shapes(1).Fill.ForeColor.Brightness = 0.5

ObjectThemeColor

Returns or sets a color that is mapped to the theme color scheme.


Dim cft As ColorFormat: Set cft = 
cft.ObjectThemeColor =

RGB

Returns or sets a Long value that represents the red-green-blue value of the specified color.


Dim cft As ColorFormat: Set cft = 
cft.RGB =

SchemeColor

Returns or sets an Integer value that represents the color of a Color object, as an index in the current color.


Dim cft As ColorFormat: Set cft = 
cft.SchemeColor =

TintAndShade

Returns or sets a Single that lightens or darkens a color.

You can enter a number from -1 (darkest) to 1 (lightest) for the TintAndShade property. Zero (0) is neutral. Attempting to set this property to a value less than -1 or more than 1 results in a run-time error: "The specified value is out of range." This property works for both theme colors and nontheme colors.


Dim cft As ColorFormat: Set cft = 
cft.TintAndShade =

Type

Returns an MsoColorType value that represents the color format type.


Dim cft As ColorFormat: Set cft = 
Dim mctType As Office.MsoColorType
mctType = cft.Type