DasPete
DasPete

Reputation: 851

How to insert an embedded picture?

xlApp.activesheet.Pictures.Insert(strImagePath) inserts pictures into a spreadsheet as a linked picture. If I send the spreadsheet out of our network the images fail.

How can I place an image as an embedded image?

I am also calling this method from Access.

Upvotes: 11

Views: 42034

Answers (3)

AG9
AG9

Reputation: 1

Activesheet.Shapes.AddPicture Filename:="C:\image.jpg", LinkToFile:=msoFalse, _
        SaveWithDocument:=msoTrue, Left:=0, Top:=0, Width:=-1, Height:=-1

this works, maybe the following code can help someone too (it helped me) this is how you select the image you've just added:

ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Select

Upvotes: -1

Michael
Michael

Reputation: 4828

Note that you can set the required Width and Height parameters to -1, which then maintains the height and width of the original image!

Activesheet.Shapes.AddPicture Filename:="C:\image.jpg", LinkToFile:=msoFalse, _
        SaveWithDocument:=msoTrue, Left:=0, Top:=0, Width:=-1, Height:=-1

http://excelmatters.com/2013/11/25/default-picture-size-with-shapes-addpicture/

(Added as another answer to increase visibility as I've struggled with this problem for ages and haven't found this solution documented anywhere else.)

Upvotes: 1

JosieP
JosieP

Reputation: 3410

you can use the shapes.addpicture method

activesheet.Shapes.AddPicture Filename:="C:\test\desert.jpg", linktofile:=msoFalse, _
            savewithdocument:=msoCTrue, Left:=0, Top:=0, Width:=100, Height:=100

Upvotes: 22

Related Questions