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 to the Microsoft Publisher program file.
LinkToFile Required MsoTriState. Determines whether the picture is linked to or embedded in the publication.
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. |
SaveWithDocument Required MsoTriState. Determines whether the picture is saved as a separate file with the publication.
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 Microsoft Publisher automatically sets the width of the shape based on the picture's default width.
Height Optional Variant. The height of the shape representing the picture. Default is -1, meaning that Microsoft Publisher automatically sets the height of the shape based on the picture's default height.
If the SaveWithDocument argument is msoTrue, Microsoft 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 Microsoft Publisher (for example, "2.5 in").
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.
Dim shpPicture As Shape
Set shpPicture = ActiveDocument.Pages(1).Shapes.AddPicture _
(FileName:="C:\Pictures\Sample1.jpg", _
LinkToFile:=msoTrue, _
SaveWithDocument:=msoTrue
Left:=72, Top:=72)