PictureFormat.Recolor method (Publisher)
Changes the color of a picture in a publication.
Syntax
expression.Recolor (Color, LeaveBlackPartsBlack)
expression A variable that represents a PictureFormat object.
Parameters
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. |
Remarks
The Recolor method corresponds to the options available in the Recolor Picture dialog box (Format menu > Picture > Recolor).
Example
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
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.