Tech Support Forum banner
Status
Not open for further replies.
1 - 5 of 5 Posts

·
Registered
Joined
·
2 Posts
Discussion Starter · #1 ·
I am building a solution that will have many UserForms. I would like to write a script to get a list of the names of the UserForms. I've tried several options and have search the net with little success. The one example I did find looks something like:


Dim Obj As Object

For Each Obj In VBA.UserForms
Debug.Print Obj.name
End If
Next Obj


But there is never anything in the VBA.UserForms. Any suggestions would be appreciated.
 

·
Registered
Joined
·
160 Posts
Here's one way to get a list of UserForms in Excel.

Code:
Sub list_user_forms()
    Dim Obj As Object
    For Each Obj In ThisWorkbook.VBProject.VBComponents
        If Obj.Type = 3 Then
            Debug.Print Obj.Name
        End If
    Next Obj
End Sub
 

·
Registered
Joined
·
2 Posts
Discussion Starter · #3 ·
Yes, this is one way to get them. Thank you. BUT... (and you knew it was coming :smile:)

In order to use this method you need to open your security options. If you will open Excel and select Tools->Macros->Security and then select the Trusted Publisher tab, you will see a check box titled "Trust access to Visual Basic Project". If the box is checked you can use this method, but if it is unchecked you get an error. Checking this box has been deemed a security risk by IS and allows for code interjection. (This is what I have been told, but have know personal experience how to do it or what can be done.)

So, the bottom line is, I need to find a different way, if it is even possible.
 

·
Registered
Joined
·
160 Posts
You're absolutely right about the security options. I certainly would be interested in an alternate way of getting UserForm information without having to change security settings, if anyone has come up with such a method.
 
1 - 5 of 5 Posts
Status
Not open for further replies.
Top