Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Determine if a userform is visible

Is this the only way to determine if a userform is
visible? :

if (Userform.Visible = true) then
' code here
end if

The problem with this code is that it seems to automatically
run the Userform_Initialize() routine. I'm wondering how
can I detect if a userform is visible without causing the
Userform_Initialize() routine to get invoked??

Thanks







  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default Determine if a userform is visible

Robert Crandal wrote:
Is this the only way to determine if a userform is
visible? :

if (Userform.Visible = true) then
' code here
end if

The problem with this code is that it seems to automatically
run the Userform_Initialize() routine. I'm wondering how
can I detect if a userform is visible without causing the
Userform_Initialize() routine to get invoked??

Thanks



using "userform." will automaticaly trigger loading userform and
executing userform_initialize.

You can try that:

a) set a global variable to true in userform_initialize

b) read this http://www.ozgrid.com/forum/showthread.php?t=152892
(I did not try that just check)








  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Determine if a userform is visible

You can set a variable to a new instance of the userform and test its
existence...

Dim MyFrm As Userform
Set MyFrm = New Userform1 '//create an instance

If Not MyFrm Is Nothing Then...

...and in the case where you keep the userform loaded but not
necessarily visible...

If Not MyFrm Is Nothing Then MyFrm.Visible = True

Witek has another good suggestion that may be helpful in managing
multiple instances or a series of userforms. Though, where a series is
needed I prefer to use 'pages' on a single form because IMO it's easier
to manage multiple pages than multiple userforms<g.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default Determine if a userform is visible

A simple approach to testing if a UserForm is either loaded or visible
without actually loading the UserForm or invoking the 'UserForm_Initialize':

http://www.EXCELGAARD.dk/Lib/UserForms/UserFormState/


CE



Den 11.05.2013 11:56, Robert Crandal skrev:
Is this the only way to determine if a userform is
visible? :

if (Userform.Visible = true) then
' code here
end if

The problem with this code is that it seems to automatically
run the Userform_Initialize() routine. I'm wondering how
can I detect if a userform is visible without causing the
Userform_Initialize() routine to get invoked??

Thanks







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Determine if a userform is visible

"witek" wrote

You can try that:

a) set a global variable to true in userform_initialize


Hi witek..... if I set my global variable to true in
Userform_Initialize(), won't this leave the possibly of
that variable being set to true even when the userform
is NOT actually visible?

I mean, if I run the following code then the variable
will be set to true while the form is not even visible:

' This code will run Userform_Initialize and
' cause my global variable to be set to true
'
if (Userform.Visible = true) then
' My code here
end if

If I set my global variable to true in Userform_Initialize(),
should I set it to false in Userform_Terminate()?




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Determine if a userform is visible

Use the Terminate event to reset the variable!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default Determine if a userform is visible

Robert Crandal wrote:
"witek" wrote

You can try that:

a) set a global variable to true in userform_initialize


Hi witek..... if I set my global variable to true in
Userform_Initialize(), won't this leave the possibly of
that variable being set to true even when the userform
is NOT actually visible?

I mean, if I run the following code then the variable
will be set to true while the form is not even visible:

' This code will run Userform_Initialize and
' cause my global variable to be set to true
'
if (Userform.Visible = true) then
' My code here
end if

If I set my global variable to true in Userform_Initialize(),
should I set it to false in Userform_Terminate()?




so do not use show. use your own code to show it at keep status somewhere.


load userform1
userform1.MyShow
unlaod userform1


and write myshow as part of userform1 with .show in it.


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
Determine tje last visible row on the screen. SpeeD Excel Programming 6 January 14th 11 08:24 AM
A way to Determine visible cells on the page Mark Stephens Excel Programming 1 June 2nd 08 05:51 PM
Determine if a PivotField is visible? Whitney Yiu Excel Programming 7 December 22nd 07 06:33 AM
Determine upper visible corner of sheet John Michl Excel Programming 2 May 4th 06 04:14 PM
Programmatically determine if a control is .VISIBLE or not. Toby Erkson Excel Programming 2 April 16th 04 11:51 PM


All times are GMT +1. The time now is 01:45 AM.

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

About Us

"It's about Microsoft Excel"