April 9, 2024
Contribute to the Microsoft 365 and Office forum!
Click here to learn more 💡
May 10, 2024
Excel Forum Top Contributors:
for each userform in vbcomponents
Report abuse
Thank you.
Reported content has been submitted
Remember to load all forms you need (Load UserForm1, Load UserForm2) and then try to use this code:
<CODE>
For Each xForm In UserForms
For Each xControl In xForm.Controls
If xControl.Name = "imgTSC" Then
xControl.Picture = LoadPicture("C:\Users\Michael\LOGOS\TSC_small.jpg")
End If
Next xControl
Next xForm
</CODE>
You can read more about LoadPicture Function at
http://msdn.microsoft.com/en-us/library/aa264946(v=vs.60).aspx website.
Report abuse
Thank you.
Reported content has been submitted
2 people found this reply helpful
·Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Report abuse
Thank you.
Reported content has been submitted
2 people found this reply helpful
·Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
You should not use For Each xForm In ThisWorkbook.VBProject.UserForms in VBA code. Instead you should use For Each xForm In UserForms.
If you have more than one userform, you should set ShowModal Property to false or load these forms and/or show them in modeless mode (to get them all in UserForms collection), like this:
<CODE>
Load UserForm1
Load UserForm2
UserForm1.Show vbModeless
UserForm2.Show vbModeless
</CODE>
and then you can use a 'For Next' loop.
You can read more at http://support.microsoft.com/kb/829070 and http://support.microsoft.com/kb/207714.
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Report abuse
Thank you.
Reported content has been submitted
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.
How satisfied are you with this reply?
Thanks for your feedback.
Question Info
Last updated October 5, 2021 Views 1,226 Applies to: