MrRhodes2004
11-07-2016, 06:56 AM
Sub UnloadAllForms()
Dim frm As UserForm
For Each frm In UserForms
Debug.Print frm.Caption 'always shows as ""
If frm.Caption <> "NavScreen" Then 'this never procs
Unload frm 'all forms are unloaded
End If
Next frm
End Sub
With the above code, I am trying to unload all of the possible forms that may be open. Depending on user interaction, there may be several forms open. I would like to unload them all with the exception of the main navigation screen using a loop. The above works well for unloading all but not for identifying which are being unloaded.
I have tried to unload them all and then just reload the NavScreen but it "flickers" and it seems to bother people.
I have tried to debug.print the frm.caption but is always shows "".
Is there better way?
Dim frm As UserForm
For Each frm In UserForms
Debug.Print frm.Caption 'always shows as ""
If frm.Caption <> "NavScreen" Then 'this never procs
Unload frm 'all forms are unloaded
End If
Next frm
End Sub
With the above code, I am trying to unload all of the possible forms that may be open. Depending on user interaction, there may be several forms open. I would like to unload them all with the exception of the main navigation screen using a loop. The above works well for unloading all but not for identifying which are being unloaded.
I have tried to unload them all and then just reload the NavScreen but it "flickers" and it seems to bother people.
I have tried to debug.print the frm.caption but is always shows "".
Is there better way?