View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default userform and variable

thanks for the link, tom. looks like this is what i wanted

uform = "Userform1"
With VBA.UserForms.Add(uForm)
.Show
.Top = 100
End With

--


Gary


"Tom Ogilvy" wrote in message
...
Userforms is the collection of loaded userforms. Since you don't have any
loaded, it correctly reports zero.

Here is a bit more detail:

http://support.microsoft.com/kb/213574/en-us
XL2000: How to Display a UserForm Whose Name Is in a Variable

http://support.microsoft.com/kb/207714/en-us
XL2000: Run-Time Errors Using UserForms Collection

Then you will see the inspiration for Bob's code.

--
Regards,
Tom Ogilvy






"John Coleman" wrote:

Hi Bob,

What is UserForms? I can't find it in the documentation. From your code
fragment it looks like a collection - but I created a spreadsheet with
2 userforms and when I type "?UserForms.Count" in the immediate window
I get 0 rather than 2. Is there any way to do something like the
following code fragment wants to do:

UserForms(myForm).Show

where myForm is a string variable? I know that you can do this sort of
thing for embedded active X controls via the Shapes collection.

Just curious - I can't imagine where I would need it in my code.

-John Coleman

Bob Phillips wrote:
Is this the sort of thing you had in mind


Dim oUserForm As Object
On Error GoTo err
Set oUserForm = UserForms.Add("Userform1")
'...

With oUserform
.Show


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
"John Bundy" wrote in message
...
Don't think so, what are you trying to accomplish? Actually i'm not even
sure
of the question, are you just wanting to change the name of the userform?
or
set the name to a variable?

"Gary Keramidas" wrote:

anyway to set a userform name to a variable i can use with <variable
name
instead of with userform1, with userform2, etc?

--


Gary