Share via


Color Property

Returns or sets the primary color of the specified object. Read/write Variant.

Remarks

When you set this property, you can use either a Long value representing a red-green-blue color value or a String value naming a valid HTML color value. For example, to set the object color to red, you could use the hexadecimal value &HFF, the decimal value 255, or the string value "red." In Microsoft Visual Basic, you can use the RGB function to create a red-green-blue color value (red is RGB(255,0,0)).

This property always returns the color as a Long value representing a red-green-blue color value.

On charts, you can also use either of the following two special constants: chColorAutomatic (to reset the color to the default value) or chColorNone (to indicate no color, or transparency). However, you cannot set a font color to chColorNone.

Example

This example adds a medium-weight green border to all cells in the range B5:C10 on the spreadsheet.

  Sub SetBorder()
  Set ssConstants = Spreadsheet1.Constants

    Spreadsheet1.ActiveSheet.Range("b5:c10").Borders.Weight = ssConstants.owcLineWeightMedium
    Spreadsheet1.ActiveSheet.Range("b5:c10").Borders.Color = "green"
End Sub