Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed Image to Excel Spreadsheet - VBA

I need to embed an image to a spreadsheet via Excel VBA, such that whenever I relocate my excel file, the image will still show up. How can I do this?

like image 975
RandomDude Avatar asked Sep 12 '11 02:09

RandomDude


People also ask

Can you embed a photo in an Excel spreadsheet?

Insert Picture from your computer Click the location in your worksheet where you want to insert a picture. On the Insert ribbon, click Pictures. Select This Device… Browse to the picture you want to insert, select it, and then click Open.


1 Answers

This code will insert an image on the current sheet and position it at at cell E10:

Set oPic = Application.ActiveSheet.Shapes.AddPicture("d:\temp\mypic.jpg", False, True, 1, 1, 1, 1)
oPic.ScaleHeight 1, True
oPic.ScaleWidth 1, True

oPic.Top = Range("E10").Top
oPic.Left = Range("E10").Left
like image 60
PaulStock Avatar answered Sep 20 '22 07:09

PaulStock