How check if form is loaded?

  • Thread starter Thread starter Jos Vens
  • Start date Start date
Jos Vens said:
Hi,

is it possible to check if a specific form is loaded into memory?

Thanks,
Jos Vens

It's possible to test whether a form is being shown. That's perhaps not what
you meant.

/Fredrik
 
Hi Fredrik,

yes it is, I just want to test if a form is shown or not but how?

Thanks
Jos
 
Hi Jos,

Private Function FormIsLoaded(UFName As String) As Boolean
Dim UF As Integer
For UF = 0 To VBA.UserForms.Count - 1
FormIsLoaded = UserForms(UF).Name = UFName
If FormIsLoaded Then Exit Function
Next UF
End Function

Sub Test()
'Load UserForm1
MsgBox FormIsLoaded("UserForm1"), 64
'If FormIsLoaded("UserForm1") Then Unload UserForm1
End Sub

Regards,
MP
 
Take it easy! Just try this code below:

PHP:
 Private Sub CommandButton1_Click()
     If (UserForm1 Is Nothing) Then
         MsgBox "UserForm1 is inactive"
     ElseIf Not UserForm1.Visible Then
         MsgBox "UserForm1 is inactive"
     Else
         MsgBox "UserForm1 is active"
     End If
 End Sub
 
Back
Top