View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Hiding a userform properly!

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!