Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Code, is user form open

I am trying to find code for indentifying if a user form is open

Thanks

SPB
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
See User Form On Open wx4usa Excel Discussion (Misc queries) 13 October 23rd 08 02:56 PM
Open a user form Pietro Excel Discussion (Misc queries) 1 August 29th 07 12:03 PM
Open Only the User Form ... or Close Everything ! monir Excel Programming 4 April 2nd 06 09:30 PM
use a button to open a user form? Hru48 Excel Discussion (Misc queries) 1 September 1st 05 07:41 PM
User Form Code mully New Users to Excel 9 May 22nd 05 07:54 PM


All times are GMT +1. The time now is 09:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"