View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default UserForm Initialize Problem

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.

--
Regards,
Tom Ogilvy





"DeathSurfer" wrote:

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.