Looping through images on a userform

G

Guest

How can I loop through the images on a userform? Can I add a variable counter
as the numeric part of the default image names image1, Image2 etc? Basically
I want to display multiple (dynamic) charts on a userform, so want to loop
through each image and load it's associated image file (of a chart, which is
saved when the workbook is opened). I could do it the long way by coding each
image to it's graphic file, but was looking for a more elegant solution using
a loop.
Regards and thanks,
Mark
 
G

Guest

Dim im as MsForms.Image
for i = 1 to 10
set im = Userform1.Controls("Image" & i)
Next
 
G

Guest

Fantastic, Many thanks Tom.

Er, next snag - can I auto scale the imported graphic files to fit the image
frames?

Regards,

Mark
 
G

Guest

Setting the PictureClipSizeMode to fmPictureSizeModeZoom (1)

worked for me although looking at the help would not indicate that it would
do it. So I can't say it will work for every picture. Try it and see. I
did it manually and set it after the picture was loaded using the default of
clipping the picture - don't know if that makes a difference.

If that won't work, then you will need to size it before using the export
method (I assume that is what you are using).
 
G

Guest

Thanks again Tom.

Tom Ogilvy said:
Setting the PictureClipSizeMode to fmPictureSizeModeZoom (1)

worked for me although looking at the help would not indicate that it would
do it. So I can't say it will work for every picture. Try it and see. I
did it manually and set it after the picture was loaded using the default of
clipping the picture - don't know if that makes a difference.

If that won't work, then you will need to size it before using the export
method (I assume that is what you are using).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top