View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Nigel Nigel is offline
external usenet poster
 
Posts: 923
Default 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