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

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
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,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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