View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
p45cal[_188_] p45cal[_188_] is offline
external usenet poster
 
Posts: 1
Default Hiding a "Userform" instead of closing it???


Robert Crandal;566072 Wrote:
I have a push button on my spreadsheet which loads my Userform
in the following manner:

Sub Button1_Click()
UserForm1.Show (vbModeless) ' Display my Userform
End Sub

When a user presses the "X" button on the Userform object
I believe that Excel will terminate the Userform instead of
simply "hiding" it by making it invisible. How can I program
my Userform to turn invisible instead of terminating itself??

I would rather have the Userform turn invisible so it can
maintain its current position on the screen when it is
re-activated again..... I noticed that the Userform position
gets reset to default after the form is terminated, and I want
to avoid this.

Thank you!


To answer your original question, put this code in the user form's code
modlue:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As
Integer)
If CloseMode = 0 Then '(closemode = 0 means x in top right was
clicked)
Cancel = True
Me.Hide
End If
End Sub

The form still exists, controls values too, for when -.show- gets
executed again


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=156259

Microsoft Office Help