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?
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With