Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listing Userform Names
Hi All
I am trying to list all userform controls. Part of this process requires that I also show the userform name and caption. In testing I discover an anomoly, that I cannot resolve - the first test below works and correctly prints the userform name and caption. the second does not work - can someone explain why please? ' this works Debug.Print ufReport.Name, ufReport.Caption ' this does not work? Dim uf As UserForm Load ufReport For Each uf In UserForms Debug.Print uf.Name, uf.Caption Next Unload ufReport |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listing Userform Names
I know you are looking for an explanation to your question. I do not have
that. However, you could iterate through the forms like this(if they are already loaded) For i = 1 To UserForms.Count Debug.Print UserForms(i - 1).Name Next i "Nigel RS" wrote: Hi All I am trying to list all userform controls. Part of this process requires that I also show the userform name and caption. In testing I discover an anomoly, that I cannot resolve - the first test below works and correctly prints the userform name and caption. the second does not work - can someone explain why please? ' this works Debug.Print ufReport.Name, ufReport.Caption ' this does not work? Dim uf As UserForm Load ufReport For Each uf In UserForms Debug.Print uf.Name, uf.Caption Next Unload ufReport |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listing Userform Names
While I do not have an answer to your good question as I too have wondered
about that.. here is another way of iterating through the loaded collection of forms For i = 1 To UserForms.Count Debug.Print UserForms(i - 1).Name Next i "Nigel RS" wrote: Hi All I am trying to list all userform controls. Part of this process requires that I also show the userform name and caption. In testing I discover an anomoly, that I cannot resolve - the first test below works and correctly prints the userform name and caption. the second does not work - can someone explain why please? ' this works Debug.Print ufReport.Name, ufReport.Caption ' this does not work? Dim uf As UserForm Load ufReport For Each uf In UserForms Debug.Print uf.Name, uf.Caption Next Unload ufReport |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listing Userform Names
That is because a user form does not exist in the userforms collection until
after it has been loaded. -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Nigel RS" wrote in message ... Hi All I am trying to list all userform controls. Part of this process requires that I also show the userform name and caption. In testing I discover an anomoly, that I cannot resolve - the first test below works and correctly prints the userform name and caption. the second does not work - can someone explain why please? ' this works Debug.Print ufReport.Name, ufReport.Caption ' this does not work? Dim uf As UserForm Load ufReport For Each uf In UserForms Debug.Print uf.Name, uf.Caption Next Unload ufReport |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listing Userform Names
This will return nothing in most instances, unless the userforms have been
loaded. -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Alok" wrote in message ... I know you are looking for an explanation to your question. I do not have that. However, you could iterate through the forms like this(if they are already loaded) For i = 1 To UserForms.Count Debug.Print UserForms(i - 1).Name Next i "Nigel RS" wrote: Hi All I am trying to list all userform controls. Part of this process requires that I also show the userform name and caption. In testing I discover an anomoly, that I cannot resolve - the first test below works and correctly prints the userform name and caption. the second does not work - can someone explain why please? ' this works Debug.Print ufReport.Name, ufReport.Caption ' this does not work? Dim uf As UserForm Load ufReport For Each uf In UserForms Debug.Print uf.Name, uf.Caption Next Unload ufReport |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listing Userform Names
Sorry for the similar two responses already to your question. The first time
I got an error and thought the response did not go through. Here is anothe way that I found one can iterate Dim uf As Object For Each uf In UserForms Debug.Print uf.Caption Next uf This is taken from Chip Pearson's explanation. http://groups.google.com/group/micro...3e7c01 a6ff7f "Nigel RS" wrote: Hi All I am trying to list all userform controls. Part of this process requires that I also show the userform name and caption. In testing I discover an anomoly, that I cannot resolve - the first test below works and correctly prints the userform name and caption. the second does not work - can someone explain why please? ' this works Debug.Print ufReport.Name, ufReport.Caption ' this does not work? Dim uf As UserForm Load ufReport For Each uf In UserForms Debug.Print uf.Name, uf.Caption Next Unload ufReport |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listing Userform Names
Bob,
I did say that.? "Bob Phillips" wrote: This will return nothing in most instances, unless the userforms have been loaded. -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Alok" wrote in message ... I know you are looking for an explanation to your question. I do not have that. However, you could iterate through the forms like this(if they are already loaded) For i = 1 To UserForms.Count Debug.Print UserForms(i - 1).Name Next i "Nigel RS" wrote: Hi All I am trying to list all userform controls. Part of this process requires that I also show the userform name and caption. In testing I discover an anomoly, that I cannot resolve - the first test below works and correctly prints the userform name and caption. the second does not work - can someone explain why please? ' this works Debug.Print ufReport.Name, ufReport.Caption ' this does not work? Dim uf As UserForm Load ufReport For Each uf In UserForms Debug.Print uf.Name, uf.Caption Next Unload ufReport |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listing Userform Names
Sub test()
Dim oVBP As Object ' VBProject Dim oCmp As Object ' VBComponent Dim ctl As Control For Each oCmp In ThisWorkbook.VBProject.VBComponents If oCmp.Type = 3& Then ' userform module Debug.Print oCmp.Name For Each ctl In oCmp.designer.Controls Debug.Print , ctl.Name Next End If Next End Sub You would need Trust access to VBProjects but not necessary to load the forms Regards, Peter T "Nigel RS" wrote in message ... Hi All I am trying to list all userform controls. Part of this process requires that I also show the userform name and caption. In testing I discover an anomoly, that I cannot resolve - the first test below works and correctly prints the userform name and caption. the second does not work - can someone explain why please? ' this works Debug.Print ufReport.Name, ufReport.Caption ' this does not work? Dim uf As UserForm Load ufReport For Each uf In UserForms Debug.Print uf.Name, uf.Caption Next Unload ufReport |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listing Userform Names
I see. Nut do not understand why?
If I define uf as a userform my code fails, if I define it as an object and then declare it in the loop by assigning each userform it does!! Not very intuitive, but then you live and learn Many thanks for the feedback -- Cheers Nigel "Alok" wrote in message ... Sorry for the similar two responses already to your question. The first time I got an error and thought the response did not go through. Here is anothe way that I found one can iterate Dim uf As Object For Each uf In UserForms Debug.Print uf.Caption Next uf This is taken from Chip Pearson's explanation. http://groups.google.com/group/micro...3e7c01 a6ff7f "Nigel RS" wrote: Hi All I am trying to list all userform controls. Part of this process requires that I also show the userform name and caption. In testing I discover an anomoly, that I cannot resolve - the first test below works and correctly prints the userform name and caption. the second does not work - can someone explain why please? ' this works Debug.Print ufReport.Name, ufReport.Caption ' this does not work? Dim uf As UserForm Load ufReport For Each uf In UserForms Debug.Print uf.Name, uf.Caption Next Unload ufReport |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Listing Userform Names
Neat way of avoiding the loading issue. thanks
-- Cheers Nigel "Peter T" <peter_t@discussions wrote in message ... Sub test() Dim oVBP As Object ' VBProject Dim oCmp As Object ' VBComponent Dim ctl As Control For Each oCmp In ThisWorkbook.VBProject.VBComponents If oCmp.Type = 3& Then ' userform module Debug.Print oCmp.Name For Each ctl In oCmp.designer.Controls Debug.Print , ctl.Name Next End If Next End Sub You would need Trust access to VBProjects but not necessary to load the forms Regards, Peter T "Nigel RS" wrote in message ... Hi All I am trying to list all userform controls. Part of this process requires that I also show the userform name and caption. In testing I discover an anomoly, that I cannot resolve - the first test below works and correctly prints the userform name and caption. the second does not work - can someone explain why please? ' this works Debug.Print ufReport.Name, ufReport.Caption ' this does not work? Dim uf As UserForm Load ufReport For Each uf In UserForms Debug.Print uf.Name, uf.Caption Next Unload ufReport |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Listing names and id and corresponding software | Excel Worksheet Functions | |||
Userform listing | Excel Programming | |||
Listing all userform controls | Excel Programming | |||
Listing the names of your worksheets | Excel Discussion (Misc queries) | |||
Listing of Sheet names | Excel Worksheet Functions |