Name
shapes.AddPicture(Filename, LinkToFile, SaveWithDocument, Left, Top, Width, Height)
Synopsis
Adds a picture to a worksheet or chart and the picture’s Shape object.
|
Argument |
Settings |
|---|---|
|
|
The picture file to load. |
|
|
True links the shape to the picture file; False copies the image into the file. |
|
|
True saves the image in the workbook; False saves only link information in the document. If |
|
|
The horizontal position of the shape in points. |
|
|
The vertical position of the shape in points. |
|
|
The width of the shape in points. |
|
|
The height of the shape in points. |
Excel scales the image to fit the Width and Height arguments. To restore the image’s actual height and width, use the ScaleHeight and ScaleWidth methods as shown here:
Sub DrawPicture( )
Dim ws As Worksheet, s As Shape
Set ws = ActiveSheet
' Insert the image.
Set s = ws.Shapes.AddPicture(ThisWorkbook.Path & "\logo.bmp", _
False, True, 100, 100, 1, 1)
' Use picture's height and width.
s.ScaleHeight 1, msoCTrue
s.ScaleWidth 1, msoCTrue
End SubUse the PictureFormat property to control a picture’s brightness, contrast, and transparency.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access