Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Determine tje last visible row on the screen. | Excel Programming | |||
A way to Determine visible cells on the page | Excel Programming | |||
Determine if a PivotField is visible? | Excel Programming | |||
Determine upper visible corner of sheet | Excel Programming | |||
Programmatically determine if a control is .VISIBLE or not. | Excel Programming |