Colors Property
Collapse the table of content
Expand the table of content

Workbook.Colors Property


Gets or sets colors in the palette for the workbook.

Namespace:   Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

Workbook_ColorsType Colors { get; }

Property Value

Type: Microsoft.Office.Tools.Excel.Workbook_ColorsType

An RGB color value in the color palette for the workbook, or an array that contains all 56 RGB color values in the color palette for the workbook.

The Colors property can be used with the following parameter.




The index number of a color in the workbook color palette (from 1 to 56). If this argument is not specified, this property returns an array that contains all 56 of the colors in the palette.

If you attempt to use Colors without specifying any parameters, Colors will get a T:Microsoft.Office.Tools.Excel.Workbook._ColorsType object that is part of the Office development tools in Visual Studio infrastructure and is not intended to be used directly from your code.

The workbook palette has 56 entries, each represented by an RGB value.

For information on optional parameters, see Optional Parameters in Office Solutions.

The following code example uses the Colors property to set the first color in the workbook's color palette to blue, and then programmatically displays the Microsoft Office Excel Color Palette dialog to verify that this change was made.

This version is for an application-level add-in.

private void SetFirstColorInPalette()
    Workbook vstoWorkbook = Globals.Factory.GetVstoObject(this.Application.ActiveWorkbook);
    vstoWorkbook.Colors[1] = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Blue);

Return to top
© 2016 Microsoft