Looping through images on a userform
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 |
Looping through images on a userform
Dim im as MsForms.Image
for i = 1 to 10 set im = Userform1.Controls("Image" & i) Next -- Regards, Tom Ogilvy "Zarch" wrote: 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 |
Looping through images on a userform
Fantastic, Many thanks Tom.
Er, next snag - can I auto scale the imported graphic files to fit the image frames? Regards, Mark "Tom Ogilvy" wrote: Dim im as MsForms.Image for i = 1 to 10 set im = Userform1.Controls("Image" & i) Next -- Regards, Tom Ogilvy "Zarch" wrote: 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 |
Looping through images on a userform
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). -- Regards, Tom Ogilvy "Zarch" wrote: Fantastic, Many thanks Tom. Er, next snag - can I auto scale the imported graphic files to fit the image frames? Regards, Mark "Tom Ogilvy" wrote: Dim im as MsForms.Image for i = 1 to 10 set im = Userform1.Controls("Image" & i) Next -- Regards, Tom Ogilvy "Zarch" wrote: 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 |
Looping through images on a userform
Thanks again Tom.
"Tom Ogilvy" wrote: 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). -- Regards, Tom Ogilvy "Zarch" wrote: Fantastic, Many thanks Tom. Er, next snag - can I auto scale the imported graphic files to fit the image frames? Regards, Mark "Tom Ogilvy" wrote: Dim im as MsForms.Image for i = 1 to 10 set im = Userform1.Controls("Image" & i) Next -- Regards, Tom Ogilvy "Zarch" wrote: 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 |
All times are GMT +1. The time now is 05:21 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com