Table of contents
TOC
Collapse the table of content
Expand the table of content

PictureFormat.Recolor Method (Publisher)

office 365 dev account|Last Updated: 8/24/2017
|
3 Contributors

Changes the color of a picture in a publication.

Syntax

expression. Recolor( Color, LeaveBlackPartsBlack)

_expression_A variable that represents a PictureFormat object.

Parameters

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.

Remarks

The Recolor method corresponds to the options available in the Recolor Picture dialog box. (On the Format menu, click Picture, and then click 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
© 2018 Microsoft