How check if form is loaded?

J

Jos Vens

Hi,

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

Thanks,
Jos Vens
 
F

Fredrik Wahlgren

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
 
J

Jos Vens

Hi Fredrik,

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

Thanks
Jos
 
M

Michel Pierron

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
 
Joined
Jun 15, 2010
Messages
1
Reaction score
0
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Menu ID of Shortmenu (Right click) 4
Change font and size of a textbox 2
Floating Form 2
Uninstall Addin 2
File size 2
Carriage return in a cell 2
Flip comment to left 3
Use a string in a formula 8

Top