Class ColorScheme (PowerPoint VBA)

The class ColorScheme represents a color scheme, which is a set of eight colors used for the different elements of a slide, notes page, or handout, such as the title or background. (Note that the color schemes for slides, notes pages, and handouts in a presentation can be set independently.)

Set

To use a ColorScheme class variable it first needs to be instantiated, for example

Dim cse as ColorScheme
Set cse = ActivePresentation.ColorSchemes(Index:=1)

The following procedures can be used to set variables of type ColorScheme: ColorSchemes.Item, ColorSchemes.Add, Master.ColorScheme, Slide.ColorScheme, SlideRange.ColorScheme and Presentation.ColorSchemes

Colors

Returns an RGBColor object that represents a single color in a color scheme.

Syntax : expression.Colors (SchemeColor)

SchemeColor: The individual color in the specified color scheme.

Dim rgbColors As RGBColor
Set rgbColors = ActivePresentation.ColorSchemes(1).Colors(SchemeColor:=ppAccent1)

Count

Returns the number of objects in the specified collection.

Dim lngCount As Long
lngCount = ActivePresentation.ColorSchemes(1).Count

Delete

Deletes the specified ColorScheme object.

ActivePresentation.ColorSchemes(1).Delete

Parent

Returns the parent object for the specified object.

ColorSchemes.Add

Adds a color scheme to the collection of available schemes. Returns a ColorScheme object that represents the added color scheme.

The new color scheme is based on the colors used on the specified slide or master or on the colors in the specified color scheme from an open presentation. The ColorSchemes collection can contain up to 16 color schemes. If you need to add another color scheme and the ColorSchemes collection is already full, use the Delete method to remove an existing color scheme. Note that although Microsoft PowerPoint automatically checks whether a color scheme is a duplicate when a user attempts to add it by using the user interface, PowerPoint doesn't check when you attempt to add a color scheme programmatically. Your procedure must do its own checking to avoid adding redundant color schemes.

Syntax : expression.Add (Scheme)

Scheme: The color scheme to add. Can be a ColorScheme object from any slide or master or an item in the ColorSchemes collection from any open presentation. If you omit this parameter, the first ColorScheme object (the first standard color scheme) in the specified presentation's ColorSchemes collection is used.

Dim cse As ColorScheme
Set cse = ActivePresentation.ColorSchemes.Add()

ColorSchemes.Count

Returns the number of objects in the specified collection.

Dim lngCount As Long
lngCount = ActivePresentation.ColorSchemes.Count

ColorSchemes.Item

Returns a single ColorScheme object from the specified ColorSchemes collection.

Syntax : expression.Item (Index)

Index: The index number of the single ColorScheme object in the collection to be returned.

Dim cse As ColorScheme
Set cse = ActivePresentation.ColorSchemes(Index:=1)

ColorSchemes.Parent

Returns the parent object for the specified object.