Compartilhar via


WorkbookBase.Colors Property

Definition

Gets or sets colors in the palette for the workbook.

public:
 property Microsoft::Office::Tools::Excel::Workbook_ColorsType ^ Colors { Microsoft::Office::Tools::Excel::Workbook_ColorsType ^ get(); };
public Microsoft.Office.Tools.Excel.Workbook_ColorsType Colors { get; }
member this.Colors : Microsoft.Office.Tools.Excel.Workbook_ColorsType
Public ReadOnly Property Colors As Workbook_ColorsType

Property Value

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.

Examples

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 example is for a document-level customization.

private void SetFirstColorInPalette()
{
    this.Colors[1] = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Blue);

    this.Application.Dialogs[
        Excel.XlBuiltInDialog.xlDialogColorPalette].Show();
}
Private Sub SetFirstColorInPalette()
    Me.Colors(1) = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Blue)
    Me.Application.Dialogs( _
        Excel.XlBuiltInDialog.xlDialogColorPalette).Show()
End Sub

Remarks

The Colors property can be used with the following parameter.

Parameter Description
Index 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 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.

Optional Parameters

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

Applies to