Play with this:
Sub abc()
Dim frm As Object, frm1 As Object
If UserForms.Count > 0 Then
For Each frm In useforms
Unload frm
Next
End If
If Rnd() < 0.5 Then
Load maintenance
maintenance.Show vbModeless
Else
Load flightlog
flightlog.Show vbModeless
End If
namevis = ""
Set frm1 = Nothing
For Each frm In UserForms
Debug.Print TypeName(frm)
If LCase(frm.Name) = "flightlog" Then
If frm.Visible Then
namevis = "flightlog"
Set frm1 = frm
Exit For
End If
ElseIf LCase(frm.Name) = "maintenance" Then
If frm.Visible Then
namevis = "maintenance"
Set frm1 = frm
Exit For
End If
End If
Next
If Not frm1 Is Nothing Then
MsgBox namevis & " is the open form"
End If
Unload frm1
End Sub
--
Regards,
Tom Ogilvy
"Excel 2003 - SPB" wrote:
> More Details
> I have two forms (of many) [flightlog & maintenance] and I need to identify
> which one is open (only one at a time) then are always visible or closed.
>
> "Tom Ogilvy" wrote:
>
> > for each frm in Userforms
> > if lcase(frm.name) = "frmabc" then
> > ' frm is loaded
> > if frm.visible then
> > ' frm is visible
> > end if
> > end if
> > Next
> >
> > Obviously if the useform isn't loaded, then it can't be visible.
> >
> > --
> > Regards,
> > Tom Ogilvy
> >
> >
> > "Excel 2003 - SPB" wrote:
> >
> > > I am trying to find code for indentifying if a user form is open
> > >
> > > Thanks
> > >
> > > SPB
|