Showing images in a cell based on filepath

Astrid123

New Member
Joined
Sep 25, 2017
Messages
16
Hello everybody,

Im really new to VBA and Excel and my question might have been asked like a thousand times, however I still didnt manage to complete my goal. Hopefully you can help me.
What I want:
I want to show images in a cell based on a filepath. Lets say:

A1 = Flower
A2 = Dog

B1 = D:\Users\user1\Pictures\flower
B2 = D:\Users\user1\Pictures\dog

I want a picture of the flower and dog in cell C1 and C2

Do you have any suggestion?
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Rich (BB code):
' For automatically loading images into specific cells.
Function LoadImage(PicFile As String) As Boolean
Dim AC As Range
On Error GoTo Done
Set AC = Application.Caller
ActiveSheet.Shapes.AddPicture PicFile, True, True, AC.Left + 2, AC.Top + 2, 100, 100
' The last two numbers above is the image dimensions in pixels.
' If you want to change the size of the images change these, keep in mind you will need to adjust
' the cell size prior to LoadImage
'
LoadImage = True
Exit Function
Done:
LoadImage = False
End Function

This drops in a new function;
Rich (BB code):
=LoadImage([URL Location])

The "100, 100" is the image size in pixels, adjust it as you see fit. I can't remember who helped me with this, but I still use it occasionally...
 
Upvote 0
Thank you for your reply!

But I think Im doing something wrong. When I type the URL location or the cell reference (=LoadImage(B2)) I get a False or an #ERROR ..

Does someone know what Im doing wrong?
 
Upvote 0

Forum statistics

Threads
1,216,731
Messages
6,132,390
Members
449,725
Latest member
Enero1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top