Label Value Loads Picture

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,060
Can anyone please provide a script that will load a picture in userform 1 based on the value in a label in the userform, the labels value would come from column A.

Say the name in A1 is movie it would then search in the following directory for movie picture. c:\ Documents\Personal, if not found it then looks in c:\ work\images

thank you
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Is anybody out there.............


Maybe something along these lines :

Code:
Private Sub UserForm_Initialize()
 
    Const PATH1 = "C:\Documents\Personal\"
    Const PATH2 = "C:\work\images\"
 
 
    If Len(Dir(PATH1 & Label1.Caption & ".jpg")) Then
 
        Set Me.Picture = LoadPicture((PATH1 & Label1.Caption & ".jpg"))
 
    ElseIf Len(Dir(PATH2 & Label1.Caption & ".jpg")) Then
 
        Set Me.Picture = LoadPicture((PATH1 & Label1.Caption & ".jpg"))
 
    End If
 
End Sub
 
Upvote 0
Thanks for your code Jaafar, works great, can you please provide a script that would also paste the picture into cell B2 on the active sheet.
 
Upvote 0
Thanks for your code Jaafar, works great, can you please provide a script that would also paste the picture into cell B2 on the active sheet.

Hi Jaye7.

You could add an Image Control to the active sheet and resize it to fit Cell B2 then load the picture onto the Image control.
 
Upvote 0
Correct me anyone but If you are using Excel 2007 or later you could insert a picture directly into the Cell.
 
Upvote 0
Thanks Jaafar,

I have never used an image control before, can you please provide a script and I will manipulate it to suite.
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,535
Members
449,037
Latest member
tmmotairi

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