Multiple images in userform

KUYJS

New Member
Joined
Sep 3, 2018
Messages
43
Hi, i have one user form which has 10 image boxes or image controllers. I want to run a loop to upload pictures to these image boxes.
How to so that?

Image1.picture = Loadpicture(imagepath)

i am not able to place i (where i = 1 to 10) as
Image i.picture = Loadpicture(imagepath i)

please help
 

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
Currently i am doing it one by one like:

Image1.picture = Loadpicture(imagepath1)

Image2.picture = Loadpicture(imagepath2)

and so on...
 
Upvote 0
I do not believe your path to the image would be
imagepath

Most file path's would look like: "C:\Users\owner\Documents\TestMe Now.xlsm"

Or something like that.<strike></strike>
 
Upvote 0
Hey,

I haave already shared the script as below:
Image1.picture = Loadpicture(imagepath1)

i have defined imagepath as string and have stored image path address to it. The way i showed it here is working perfectly fine.

My question is, instead image1.picture, can i use image i.picture. Where i is variable (integer) and will vary from 1 to 10. Ex:

For i = 1 to 10
Image i.picture = Loadpicture(imagepath i)
Next i

So that when i =1
Image1.picture = Loadpicture(imagepath1)
when i =2
Image2.picture = Loadpicture(imagepath2)

and so on...

Hoe this clarified my question
 
Upvote 0
Hey,

I haave already shared the script as below:
Image1.picture = Loadpicture(imagepath1)

i have defined imagepath as string and have stored image path address to it. The way i showed it here is working perfectly fine.

My question is, instead image1.picture, can i use image i.picture. Where i is variable (integer) and will vary from 1 to 10. Ex:

For i = 1 to 10
Image i.picture = Loadpicture(imagepath i)
Next i

So that when i =1
Image1.picture = Loadpicture(imagepath1)
when i =2
Image2.picture = Loadpicture(imagepath2)

and so on...

Hoe this clarified my question

You could use the controls collection like this :
Code:
Me.Controls("image" & i)
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,636
Latest member
laura12345

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