Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code, is user form open
I am trying to find code for indentifying if a user form is open
Thanks SPB |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code, is user form open
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code, is user form open
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code, is user form open
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code, is user form open
Thanks tom
I added another elseif for one other area i had not thought about and all is good Thanks SPB "Tom Ogilvy" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
See User Form On Open | Excel Discussion (Misc queries) | |||
Open a user form | Excel Discussion (Misc queries) | |||
Open Only the User Form ... or Close Everything ! | Excel Programming | |||
use a button to open a user form? | Excel Discussion (Misc queries) | |||
User Form Code | New Users to Excel |