AddPicture Method

Microsoft Excel Visual Basic

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 file from which the OLE object is to be created.

LinkToFile   Required MsoTriState. The file to link to.

MsoTriState can be one of these MsoTriState constants.
msoCTrue
msoFalse To make the picture an independent copy of the file.
msoTriStateMixed
msoTriStateToggle
msoTrue To link the picture to the file from which it was created.

SaveWithDocument   Required MsoTriState. To save the picture with the document.

MsoTriState can be one of these MsoTriState constants.
msoCTrue
msoFalse To store only the link information in the document.
msoTriStateMixed
msoTriStateToggle
msoTrue To save the linked picture with the document into which it’s inserted. This argument must be msoTrue if LinkToFile is msoFalse.

Left   Required Single. The position (in points) of the upper-left corner of the picture relative to the upper-left corner of the document.

Top   Required Single. The position (in points) of the upper-left corner of the picture relative to the top of the document.

Width   Required Single. The width of the picture, in points.

Height   Required Single. The height of the picture, in points.

Example

This example adds a picture created from the file Music.bmp to myDocument. The inserted picture is linked to the file from which it was created and is saved with myDocument.

Set myDocument = Worksheets(1)
myDocument.Shapes.AddPicture _
    "c:\microsoft office\clipart\music.bmp", _
    True, True, 100, 100, 70, 70