This documentation is archived and is not being maintained.

PictureFormat.Recolor Method

Office 2007
Changes the color of a picture in a publication.

Version Information
 Version Added:  Publisher 2007


expression.Recolor(Color, LeaveBlackPartsBlack)

expression   A variable that represents a PictureFormat object.


NameRequired/OptionalData TypeDescription
ColorRequiredColorFormatThe color to be used for recoloring.
LeaveBlackPartsBlackRequiredMsoTriStateTrue if all parts of the original picture that were black in color should be left black.


The Recolor method corresponds to the options available in the Recolor Picture dialog box. (On the Format menu, click Picture, and then click Recolor)


The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the Recolor method to change the color of a picture. It recolors the first shape in the Shapes collection on the first page of the publication. After running the code, you can restore the original colors by using the RestoreOriginalColors method.

For this example to work, the shape to be recolored must be either a picture or an OLE object that represents a picture.

Visual Basic for Applications
Public Sub Recolor_Example()

    Dim pubPictureFormat As Publisher.PictureFormat
    Dim pubShape As Publisher.Shape
    Dim pubColorFormat As Publisher.ColorFormat
    Set pubShape = ThisDocument.Pages(1).Shapes(1)
    Set pubPictureFormat = pubShape.PictureFormat
    Set pubColorFormat = pubShape.Fill.BackColor
    pubPictureFormat.Recolor pubColorFormat, msoTrue
End Sub