UserForm Initialize Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Duuuuudes:

Is there a way to check if a userform, created with vba, running inside of
Excel 03' is visible without the userforms initialize event running?

Thanks.
 
use this macro

sub test()
'You can initialize variable here
userform1.listbox1.text = "Hello"
userform1.show
end sub
 
thanks for the reply Joel but I need to know if I can check a form's
visibility status without the initialize event running on the form. I guess
this can't be done because the form has to load into memory before it can
check the visibility status.
 
You can check if it is loaded, but if you refer to it, it gets loaded.

A workaround would be to use the findwindow API function.


Something like:

Sub CheckForm()
Dim hWnd As Long
hWnd = FindWindow(vbNullString, "MyUserform Caption")
If hWnd = 0 Then
MsgBox "not visbile"
Else
MsgBox "Visible"
End If
UserForm1.Show vbModeless
hWnd = FindWindow(vbNullString, "MyUserform Caption")

If hWnd = 0 Then
MsgBox "not visbile"
Else
MsgBox "Visible"
End If

End Sub

The above code obviously loads the userform (and fires the initialize
event), but it is just to demonstrate usage.
 
Thanks Dude.



Tom Ogilvy said:
You can check if it is loaded, but if you refer to it, it gets loaded.

A workaround would be to use the findwindow API function.


Something like:

Sub CheckForm()
Dim hWnd As Long
hWnd = FindWindow(vbNullString, "MyUserform Caption")
If hWnd = 0 Then
MsgBox "not visbile"
Else
MsgBox "Visible"
End If
UserForm1.Show vbModeless
hWnd = FindWindow(vbNullString, "MyUserform Caption")

If hWnd = 0 Then
MsgBox "not visbile"
Else
MsgBox "Visible"
End If

End Sub

The above code obviously loads the userform (and fires the initialize
event), but it is just to demonstrate usage.
 
Back
Top