Importing images into userform

MrPink1986

Active Member
Joined
May 1, 2012
Messages
252
Hi,

I have a multi page user form that I am using to predict scores for the premier league soccer fixtures each week. Within each page I have 1 fixture made up of a home team and an away team. This data changes week on week depending on the a web import. I want to add two images to each page which will represent the team crest of the team in each text box.

I have the team crests on a tab named "Pictures" with each crest in a cell beginning with C2.
My text boxes are named Fixture1_Home Fixture1_Away - Fixture10_Home Fixture10_Away this will pick up the 20 teams each week.

In my image box I want some code to say if Fixture1_Home is X then pick up the picture and apply this to the image box (my image boxes are named Fix1_Home_Image, Fix1_Away_Image etc)

Once this is defined I am then presuming I can call the Sub UserForm_Initialize stage.

I have attempted the below for the Manchester United team as the away team in the fixture 9 test box.

Code:
Private Sub Fix9_Away_Image_Click()If Fixture9_Away_Change = "Manchester United" Then
Fix9_Away_Image.Picture = Sheets("Pictures").Range("C2")
End If
End Sub

Any help is greatly appreciated.
 
Re: Help importing images into userform

Apologies - I wish to have the team names and team pictures on a tab named -"Info" - I will have this tab hidden and only used as a reference.
The userform will be opened on a different tab.
I do not understand what you want :confused:
- are you asking if it is possible to have ALL the logos & team names on the same tab?
- are you referring to the userform or the worksheet
 
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Re: Help importing images into userform

Yes
- amend the code to reflect the new sheet name
- the code should work with a hidden sheet
- open the userform on any tab
 
Upvote 0
Re: Help importing images into userform

Ok cool thanks it seems I only need to change "Set Ws = Sheets("Logos")" to the name I have in my WB. Do I need the two subs to run this?
Yes
- amend the code to reflect the new sheet name
- the code should work with a hidden sheet
- open the userform on any tab
 
Upvote 0
Re: Help importing images into userform

Yes you require both subs ( but see Zipping below)

How it works
You said you wanted to distribute the workbook with the images embedded BUT my code uses the images from a folder on a local drive not from the workbook
So the images need to be placed in a folder on every computer - that is what CreateJpegs does
The recipient should only need to run this once to place the imges in the folder - they stay there unless deleted

Zipping?
Have you considered zipping the files?
- if the image files are not embedded, but 22 separate files, then the workbook and image files could be zipped together and the recipient could unzip into a single folder
- CreateJpegs would then not be required
 
Last edited:
Upvote 0
Re: Help importing images into userform

OK thanks I like the idea of each user creating the files on the drive. Do I need to define a path? How do I know where the JPEGs go?
Yes you require both subs ( but see Zipping below)

How it works
You said you wanted to distribute the workbook with the images embedded BUT my code uses the images from a folder on a local drive not from the workbook
So the images need to be placed in a folder on every computer - that is what CreateJpegs does
The recipient should only need to run this once to place the imges in the folder - they stay there unless deleted

Zipping?
Have you considered zipping the files?
- if the image files are not embedded, but 22 separate files, then the workbook and image files could be zipped together and the recipient could unzip into a single folder
- CreateJpegs would then not be required
 
Upvote 0
Re: Help importing images into userform

The macro places the files automatically in the same folder as the workbook
Unzipping would also do the same
 
Last edited:
Upvote 0
Re: Help importing images into userform

The macro places the files automatically in the same folder as the workbook
Unzipping would also do the same
Thanks for your help with this one - I now have my spreadsheet working with the pictures been generated from the sheets.
 
Upvote 0
Re: Help importing images into userform

thanks for the feedback :beerchug:
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,301
Members
452,633
Latest member
DougMo

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