By Adam Nagy
Let's say we have a VBA project with a Class, a UserForm and a Module, each with a single function in it:
When checking in the Macros dialog only the Module's function (MyModuleFunction) will be shown:
This is as designed. Both the Class and the UserForm hide their properties and functions from outside because those are instance specific. In other words, if you want to call a function of a UserForm you have to create a function in a Module which will create an instance of the UserForm and through that then you can access the form's properties and call its functions, including the one to show the form:
Public myUserForm As UserForm1 Sub MyModuleFunction() ' We create an instance of the form Set myUserForm = New UserForm1 ' Now we can access the form's functions ' and properties through the variable ' named "myUserForm" ' If you want to show it as modal, ' i.e. all the other UI is disabled ' until the dialog is dismissed, then ' just delete the word "vbModeless" ' from the below code Call myUserForm.Show(vbModeless) End Sub
Now if you call MyModuleFunction, it will show our form: