ColorScheme Object (Publisher)

Office 2013 and later
GitHub-Mark-64px

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Represents a color scheme, which is a set of eight colors used for the different elements of a publication. Each color is represented by a ColorFormat object. The ColorScheme object is a member of the ColorSchemes collection. The ColorSchemes collection contains all the color schemes available to Microsoft Publisher.

Use the ColorScheme property of a Document object to return the color scheme for the current publication. The following example sets the fill value of three shapes on the first page to the return value (in RGB format) of three of the eight ColorScheme colors.

Sub ReturnColorsAndApplyToShapes() 
 Dim lngAccent1 As Long 
 Dim lngAccent2 As Long 
 Dim lngAccent3 As Long 
 
 With ActiveDocument 
 With .ColorScheme 
 lngAccent1 = .Colors(pbSchemeColorAccent1).RGB 
 lngAccent2 = .Colors(pbSchemeColorAccent2).RGB 
 lngAccent3 = .Colors(pbSchemeColorAccent3).RGB 
 End With 
 With .Pages(1) 
 .Shapes(1).Fill.ForeColor.RGB = lngAccent1 
 .Shapes(2).Fill.ForeColor.RGB = lngAccent2 
 .Shapes(3).Fill.ForeColor.RGB = lngAccent3 
 End With 
 End With 
 
End Sub

Use the Name property to return a color scheme name. The following example lists in a text box all the color schemes available to Publisher.

Sub ListColorShemes() 
 
 Dim clrScheme As ColorScheme 
 Dim strSchemes As String 
 
 For Each clrScheme In Application.ColorSchemes 
 strSchemes = strSchemes & clrScheme.Name & vbLf 
 Next 
 ActiveDocument.Pages(1).Shapes.AddTextbox( _ 
 Orientation:=pbTextOrientationHorizontal, _ 
 Left:=72, Top:=72, Width:=400, Height:=500).TextFrame _ 
 .TextRange.Text = strSchemes 
 
End Sub
Show: