PictureFormat.Recolor Method (Publisher)

Changes the color of a picture in a publication.


expression. Recolor(Color, LeaveBlackPartsBlack)

expression A variable that represents a PictureFormat object.


Name Required/Optional Data type Description
Color Required ColorFormat The color to be used for recoloring.
LeaveBlackPartsBlack Required MsoTriState True 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.

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