userform and variable
anyway to set a userform name to a variable i can use with <variable name
instead of with userform1, with userform2, etc? -- Gary |
userform and variable
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 |
userform and variable
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 |
userform and variable
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 |
userform and variable
gary - i'd be interested in the answer to this, too, because when i
change the name of a userform to something like frmGenerate, i can't get the initialization to run.......... but i didn't think of declaring it as a variable in my global declarations module......... susan 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 |
userform and variable
bob:
i was looking to use a variable to create the userform name. so instead of with userform1, with userform2, i could use: with userform(i) .. .. end with or uform = userform1 then use the variable to manipulate the form ( i know this won't work, but) with uform .. .. end with i've used me.controls("textbox" & i) and am wondering if there is a way to do this with the form itself. Gary "Bob Phillips" wrote in message ... 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 |
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 |
userform and variable
here's the problem I've run into using VBA.UserForms.Add(uForm).
i set uform = "UF2" then VBA.UserForms.Add(uForm).show unload uf2 doesn't work. the form is still displayed. -- 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 |
userform and variable
You unload it from within the form, not the other code.
-- --- HTH Bob (change the xxxx to gmail if mailing direct) "Gary Keramidas" <GKeramidasATmsn.com wrote in message ... here's the problem I've run into using VBA.UserForms.Add(uForm). i set uform = "UF2" then VBA.UserForms.Add(uForm).show unload uf2 doesn't work. the form is still displayed. -- 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 |
userform and variable
If you have
Private Sub frmGenerate_Initialize() then that is the problem. No matter the userform name, it should always be Private Sub Userform_Initialize() -- Regards, Tom Ogilvy "Susan" wrote in message ps.com... gary - i'd be interested in the answer to this, too, because when i change the name of a userform to something like frmGenerate, i can't get the initialization to run.......... but i didn't think of declaring it as a variable in my global declarations module......... susan 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 |
userform and variable
tom - yes, that's what i have to do. but if you have a macro where
you're calling various userforms from the main macro, it would be nice to be able to differentiate them more easily, even tho i know the initialize sub is directly connected to that specific userform...... when i've got five different userform windows open it gets a little confusing LOL susan Tom Ogilvy wrote: If you have Private Sub frmGenerate_Initialize() then that is the problem. No matter the userform name, it should always be Private Sub Userform_Initialize() -- Regards, Tom Ogilvy "Susan" wrote in message ps.com... gary - i'd be interested in the answer to this, too, because when i change the name of a userform to something like frmGenerate, i can't get the initialization to run.......... but i didn't think of declaring it as a variable in my global declarations module......... susan 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 |
userform and variable
then you seem to be asking the same question as Gary, so the answer is the
same -- --- HTH Bob (change the xxxx to gmail if mailing direct) "Susan" wrote in message ups.com... tom - yes, that's what i have to do. but if you have a macro where you're calling various userforms from the main macro, it would be nice to be able to differentiate them more easily, even tho i know the initialize sub is directly connected to that specific userform...... when i've got five different userform windows open it gets a little confusing LOL susan Tom Ogilvy wrote: If you have Private Sub frmGenerate_Initialize() then that is the problem. No matter the userform name, it should always be Private Sub Userform_Initialize() -- Regards, Tom Ogilvy "Susan" wrote in message ps.com... gary - i'd be interested in the answer to this, too, because when i change the name of a userform to something like frmGenerate, i can't get the initialization to run.......... but i didn't think of declaring it as a variable in my global declarations module......... susan 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 |
All times are GMT +1. The time now is 03:32 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com