Help required with 'FOR' Loop and Userforms

C

Clinton M James

Hi All,

I remember a while back finding a website that told me how this was done,
but I can't seem to find reference anymore.

My problem is this - I have several userforms whereby i would like a "For
Each..." loop to acess so i can update the captions of each.

I know there seems to be issue with VBA finding all userforms in a project
when they have not been loaded/initialised, but I believe there is some
method that will allow me to do this without loading them. VBProjects object
will let me do this, but the problem is that the changes to the caption I
make using this method seem to end up permanent unlike if was to simply code
it like "userform1.caption = "abc"".

Permanancy is not an option because I have hard coded some info into each
userform and I am re-referencing the hard coded caption to then append other
info when the program first starts.

The caption will change once on startup, but the hardcoded captions must
stay when the project gets saved.

In short:

I require a method to go through each userform in a project without the
forms necessarily having been initialized and perform a function similar to
userform1.caption = ""

the vbproject object method isn't desirable.

If there is nobody able to help with this then through the vbproject way, I
am able to grab the name of the userform. Once I have this name, is there a
way to reference the userform like one can controls (EG
userform1.controls("textbox1") ??)

I tried the userforms method such as userforms(Object.name) but I kept
getting error. The object.name was the command that returned the userform
name, not the exact code as I don't have what I was working on exactly here
with me at the moment.

Any help is grealy appreciated and thank you in advance.

Regards,
Clint
 

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