Share via


AddPicture Method [Publisher 2003 VBA Language Reference]

Adds a new Shape object representing a picture to the specified Shapes collection.

expression.AddPicture(FileName, LinkToFile, SaveWithDocument, Left, Top, Width, Height)

expression Required. An expression that returns one of the objects in the Applies To list.

FileName  Required String. The name of the picture file to insert into the shape. The path can be absolute or relative.

MsoTriState

MsoTriState can be one of these MsoTriState constants.
msoCTrue Not used for this method.
msoFalse The picture is to be embedded in the publication.
msoTriStateMixed Not used for this method.
msoTriStateToggle Not used for this method.
msoTrue The picture is to be linked to the publication.

MsoTriState

MsoTriState can be one of these MsoTriState constants.
msoCTrue Not used for this method.
msoFalse The picture is embedded in the publication.
msoTriStateMixed Not used for this method.
msoTriStateToggle Not used for this method.
msoTrue A separate copy of the picture is saved as a new file in the same directory as the publication.

Left  Required Variant. The position of the left edge of the shape representing the picture.

Top  Required Variant. The position of the top edge of the shape representing the picture.

Width  Optional Variant. The width of the shape representing the picture. Default is -1, meaning that the width of the shape is automatically set based on the object's data.

Height  Optional Variant. The height of the shape representing the picture. Default is -1, meaning that the width of the shape is automatically set based on the object's data.

Remarks

If the SaveWithDocument argument is msoTrue, Publisher saves a new copy of the picture file specified by the FileName argument in the same directory as the publication.

The LinkToFile and SaveWithDocument arguments cannot have the same value, or else an error occurs. If either argument is msoTrue, the other must be msoFalse.

For the Left, Top, Width, and Height arguments, numeric values are evaluated in points; strings can be in any units supported by Publisher (for example, "2.5 in").

Example

The following example adds a picture based on an existing file to the active publication; the picture in the publication is linked to a copy of the original file. (Note that PathToFile must be replaced with a valid file path for this example to work.)

Dim shpPicture As Shape

Set shpPicture = ActiveDocument.Pages(1).Shapes.AddPicture _
    (FileName:="PathToFile", _
    LinkToFile:=msoTrue, _
    SaveWithDocument:=msoTrue
    Left:=72, Top:=72)

Applies to | Shapes Collection