Loading a picture from hyperlink address into a frame within a userform...

kbishop94

Active Member
Joined
Dec 5, 2016
Messages
458
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Not sure if something like this is even possible, but I thought I would ask:

I have a frame (name = "fraPicture") in a userform that when my userform loads I would like this frame to load a picture that is located in a specific folder (via hyperlink, I think?)

Ideally, I would like it to work like this (again, if its even possible):
VBA Code:
With ws
    .Cells(RecordRow, 29).value = Me.fraPicture.Picture 
End With

Where "29" is the cell location where the address to the picture is located, and fraPicture is the name of the frame where I want the picture to populate when the userform loads.

The address for the picture that is inside cell 'RecordRow, 29' looks like this: J:\QMS_General Facility\INCIDENT LOGS\Incident_Pictures\22.1191.bmp

Can something like this be done, or would I have to have the picture itself not located in a separate folder like I do now, but inside the cell in the spreadsheet itself?

Thanks for any help or suggestions to accomplish this in another way if what I am proposing cant be done or if there is a better way.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try . . .

VBA Code:
With ws
    Me.fraPicture.Picture = LoadPicture(.Cells(RecordRow, 29).Hyperlinks(1).Address) 
End With

Hope this helps!
 
Upvote 0
Solution
Try . . .

VBA Code:
With ws
    Me.fraPicture.Picture = LoadPicture(.Cells(RecordRow, 29).Hyperlinks(1).Address)
End With

Hope this helps!
That worked!! Thank you! (this has stumped me forever so a double TY to you, sir!!)
However, what you showed didnt exactly work at first... I had to remove the "." in front of the "Cells(RecordRow, 29)"... but, after that it loaded the pic perfectly. (y) (maybe edit it so if someone ever searches for this and stumbles onto it it will work for them right away. 🍺)
 
Upvote 0
You're very welcome, glad I could help.

Actually, the dot ( . ) is there so that the specified range will refer to the worksheet defined by your variable ws, just like your original code. Otherwise, without it, the range will refer to the active worksheet instead. I'm assuming that you've assigned the variable the worksheet containing the hyperlink, correct?
 
Upvote 0
So, for example, let's say that "Sheet1" contains your hyperlink, then you could have something like this . . .

VBA Code:
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")

With ws
    Me.fraPicture.Picture = LoadPicture(.Cells(RecordRow, 29).Hyperlinks(1).Address)
End With

Although, in this case, you can do without the With/End With statement . . .

VBA Code:
Me.fraPicture.Picture = LoadPicture(ws.Cells(RecordRow, 29).Hyperlinks(1).Address)
 
Upvote 0
Understood! Thank you for following up with that. It is much appreciated!!!
 
Upvote 0

Forum statistics

Threads
1,215,053
Messages
6,122,882
Members
449,097
Latest member
dbomb1414

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