how to "synchronize" VBProjects & VBA.Userforms?
"Lars Uffmann" wrote in message
...
Peter T wrote:
It's an unusual way to put it, as I mentioned VBA.UserForms refers to the
loaded Userforms within the project it's called from
It refers to that, and a little more - by referring to a collection of
those UserForms, but also providing the Add method to load new
(dynamically created) forms.
That's two separate things. First you dynamically created the form and
return is name, say sName
Second, you add it to the Userforms collection of "Loaded" forms using the
Userforms.Add(sName) method. But that's not directly relevant to the fact
you have just dynamically created it. If the form was created during design
time you could have loaded and show'n it the same way.
You could simply do
Userforms.Add(sName).Show
though it may well be better for later reasons to do it as you are and set a
reference to the Add'ed form
Generally it's best not to add code modules to the same project that's
running the code.
Well - I don't see how I could add the form dynamically to a different
project. I mean - I could add it, but then I could not dynamically load it
because I cannot access the VBA project for another project, as VBProject
does not have a VBA property, sadly.
I'm not saying it won't work, but look out for unexplained things happening
while adding controls and related event code to the form (like the code
re-compiling while running and causing a crash). Though adding code to a
form is probably somewhat safer than doing similar behind a Worksheet.
Regards,
Peter T
|