Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Please take a look at the code below which my workbook
is using: '-------------------------------------------------------- Private Sub Workbook_Open() Userform1.Show End Sub '------------------------------------------------------- Private Sub UserForm_Initialize() MsgBox "Initialize stuff here" Userform1.Hide MsgBox "Okay, form1 is hidden now!" Userform1.Show End Sub '-------------------------------------------------------- So....obviously this code will not work. I'm guessing that the second call to "Userform1.Show" is causing the program to crash. I would like to temporarily hide the form and then make it visible again. What am I doing wrong? thanks! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Not clear what the real objective is, it'd be better if you explain.
If you merely want to run the form's initialize event without showing it, Load Userform1 ' ' or anything that references the form ' initialize fires when you want to show it (and run it's Activate event) Userform1.show In passing, as looks like you are trying to run the form in the workbook open event, probably better to run it with an onTime macro, but it depends. Regards, Peter T "Robert Crandal" wrote in message ... Please take a look at the code below which my workbook is using: '-------------------------------------------------------- Private Sub Workbook_Open() Userform1.Show End Sub '------------------------------------------------------- Private Sub UserForm_Initialize() MsgBox "Initialize stuff here" Userform1.Hide MsgBox "Okay, form1 is hidden now!" Userform1.Show End Sub '-------------------------------------------------------- So....obviously this code will not work. I'm guessing that the second call to "Userform1.Show" is causing the program to crash. I would like to temporarily hide the form and then make it visible again. What am I doing wrong? thanks! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Peter,
Okay, I'll try to explain my situation more.... I actually have 2 userforms. Userform1 is typically displayed first because it contains buttons and other controls. There is a button on top of Userform1 which is designed to show Userform2. If Userform2 is displayed, I would like to hide Userform1. Once Userform2 gets closed out, I would like to re-display the same Userform1 again or bring it out of its previous hidden state. I realize that I can leave both Userform1 and Userform2 visible at the same time, but I prefer to keep Userform1 out of view if Userform2 gets triggered. Just wondering if this is possible. thanks Robert "Peter T" <peter_t@discussions wrote in message ... Not clear what the real objective is, it'd be better if you explain. If you merely want to run the form's initialize event without showing it, Load Userform1 ' ' or anything that references the form ' initialize fires when you want to show it (and run it's Activate event) Userform1.show In passing, as looks like you are trying to run the form in the workbook open event, probably better to run it with an onTime macro, but it depends. Regards, Peter T |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
The intialize code is event code - it fires when the form is loaded or shown. The crash is probably due to the .show being inside the initialize event code, which then fires the initialize, which does the .show, which fires... Don't put .Show or .Hide inside the initialize event. The initialize simply fills your form with information that you want to see when .Show happens. Sounds like all you need is to put Me.Hide Userform2.Show inside your event code for OKButton_Click in Userform1 (or whatever it is called) and similarly Me.Hide Userform1.Show inside your event code for OKButton_Click in Userform2 regards Paul On Mar 8, 10:02*am, "Robert Crandal" wrote: Peter, Okay, I'll try to explain my situation more.... I actually have 2 userforms. * *Userform1 is typically displayed first because it contains buttons and other controls. *There is a button on top of Userform1 which is designed to show Userform2. If Userform2 is displayed, I would like to hide Userform1. * Once Userform2 gets closed out, I would like to re-display the same Userform1 again or bring it out of its previous hidden state. I realize that I can leave both Userform1 and Userform2 visible at the same time, but I prefer to keep Userform1 out of view if Userform2 gets triggered. * Just wondering if this is possible. thanks Robert "Peter T" <peter_t@discussions wrote in message ... Not clear what the real objective is, it'd be better if you explain. If you merely want to run the form's initialize event without showing it, Load Userform1 ' ' or anything that references the form ' initialize fires when you want to show it (and run it's Activate event) Userform1.show In passing, as looks like you are trying to run the form in the workbook open event, probably better to run it with an onTime macro, but it depends. Regards, Peter T- Hide quoted text - - Show quoted text - |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Paul has already covered most of what I would have said.
Whilst I follow what you describe below, I don't follow it in relation to what you originally posted at all, no way to slot in stuff about hiding the form and showing some other within the Initialize event. Is this two different topics perhaps. Regards, Peter T "Robert Crandal" wrote in message ... Peter, Okay, I'll try to explain my situation more.... I actually have 2 userforms. Userform1 is typically displayed first because it contains buttons and other controls. There is a button on top of Userform1 which is designed to show Userform2. If Userform2 is displayed, I would like to hide Userform1. Once Userform2 gets closed out, I would like to re-display the same Userform1 again or bring it out of its previous hidden state. I realize that I can leave both Userform1 and Userform2 visible at the same time, but I prefer to keep Userform1 out of view if Userform2 gets triggered. Just wondering if this is possible. thanks Robert "Peter T" <peter_t@discussions wrote in message ... Not clear what the real objective is, it'd be better if you explain. If you merely want to run the form's initialize event without showing it, Load Userform1 ' ' or anything that references the form ' initialize fires when you want to show it (and run it's Activate event) Userform1.show In passing, as looks like you are trying to run the form in the workbook open event, probably better to run it with an onTime macro, but it depends. Regards, Peter T |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
UserForm Labels not Showing Properly | Excel Programming | |||
UserForm Not Hiding | Excel Programming | |||
Dynamically Hiding portions of a UserForm | Excel Programming | |||
UserForm from VBA macro is not getting properly unloaded | Excel Programming | |||
UserForm not hiding | Excel Programming |