Hi, may i know how to use VBA to check whether the form-- "form1" is open or closed?
Printable View
Hi, may i know how to use VBA to check whether the form-- "form1" is open or closed?
I think you would probably have to use the FindWindow API to do this. The reason is, any time you reference a form, it gets instantiated. So, the test:
will always evaluate to false--the form will be "not nothing" as soon as the test is made. The way around these issues would be to never let a form load implicitly. Do all of your form loading by setting a variable for the form and explicitly creating and destroying it's reference:VB Code:
If UserForm1 Is Nothing Then
VB Code:
Dim oForm As UserForm1 Set oForm = New UserForm1 oForm.Show Set oForm = Nothing