Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
From code initiated in my main form1, I want to hide form1 and show form2.
When done with form2, then re-show form1. No matter which way I try and do this, my code runs up in multiple stacks which don't terminate until final exit. In the example below, if I switch forms several tmes by pressing CommandButtons 1 & 2 on main form1, only when I finally exit are all the procedures completed. This contrived example this does not pose a problem. But with a lot of complex code involved I get a memory leak in some circumstances - in particular, when I switch forms from a popup commandbar that was created while on the main form. This memory leak persists after I exit my app. However it is a one off, ie having switched forms once in any given session of Excel, no further leak occurs. Switching forms from an OnTime macro does not appear to help. Clearly there I'm doing something wrong and would appreciate pointers. TIA, Peter T '//Userform1 with 3 CommandButtons Private Sub CommandButton1_Click() Debug.Print "UF1 UserForm2 start" Me.Hide UserForm2.Show Me.Show Debug.Print "UF1 UserForm2 end" End Sub Private Sub CommandButton2_Click() Debug.Print "UF1 run Proc1 start" Proc1 Debug.Print "UF1 run Proc1 done" End Sub Private Sub CommandButton3_Click() Debug.Print "Unload UF1" Unload Me End Sub '// end Userform1 '//Userform2 with 1 CommandButton Private Sub CommandButton1_Click() Debug.Print "unload UF2 " Unload Me End Sub '// end Userform2 '// in a normal module Sub test() UserForm1.Show End Sub Sub Proc1() Debug.Print "Proc 1 start" Proc2 Debug.Print "Proc 1 done" End Sub Sub Proc2() Debug.Print "Proc 2 start" Proc3 Debug.Print "Proc 2 done" End Sub Sub Proc3() Debug.Print "Proc 3 start" UserForm1.Hide UserForm2.Show 'comes back here when UF2 unloads UserForm1.Show Debug.Print "Proc 3 done" End Sub '// end normal module |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
column chart stacks data when i add a secondary vertical axis | Charts and Charting in Excel | |||
Obtaining Multiple Results using muliple Criteria from an Array | Excel Worksheet Functions | |||
Multiple Userforms at once | Excel Programming | |||
Multiple Userforms open at once | Excel Programming | |||
Multiple simultaneous macros and userforms | Excel Programming |