ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Accidentally close user form_how to open (https://www.excelbanter.com/excel-programming/367504-accidentally-close-user-form_how-open.html)

Hammer1947

Accidentally close user form_how to open
 
You all have been great. Next question....If I accidentally close the user
form in my program how can I get it back without restarting my excel program.
It is set to auto load at opening. I am also running modeless.
thanks!

gary

Leith Ross[_667_]

Accidentally close user form_how to open
 

Hello Gary,

Add a VBA Module to your project and place the code below in it. You
can the run it from the Macros Dialog (ALT+F8) when you need to display
the UserForm. Replace UserForm1 in the code with the name of your
UserForm.

Sub ShowMyForm()
On Error Resume Next
UserForm1.Show
End Sub

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=562333


Hammer1947

Accidentally close user form_how to open
 
Thanks Leith,
I don't want to have to Alt F8 to display the form. The form needs to be
loaded and visible at all times while the excel program is running. The only
thing I was concerned about was the close "X". If I accidentally click the
close "X" the form goes away and I can't get it back. Ideally would be to get
rid of the "X" button since I never want to close it during the running of
the program. This form has buttons on it that are always used during the
program.

gary

"Leith Ross" wrote:


Hello Gary,

Add a VBA Module to your project and place the code below in it. You
can the run it from the Macros Dialog (ALT+F8) when you need to display
the UserForm. Replace UserForm1 in the code with the name of your
UserForm.

Sub ShowMyForm()
On Error Resume Next
UserForm1.Show
End Sub

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=562333



MDubbelboer[_14_]

Accidentally close user form_how to open
 

Hammer1947 Wrote:
Thanks Leith,
I don't want to have to Alt F8 to display the form. The form needs t
be
loaded and visible at all times while the excel program is running. Th
only
thing I was concerned about was the close "X". If I accidentally clic
the
close "X" the form goes away and I can't get it back. Ideally would b
to get
rid of the "X" button since I never want to close it during the runnin
of
the program. This form has buttons on it that are always used durin
the
program.

gary


from: http://www.contextures.com/xlUserForm01.html

To prevent users from closing the form by clicking the X button:

1. Right-click on an empty part of the UserForm
2. Choose View | Code
3. Scroll to the bottom of the existing code, and enter th
following code:

Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please use the button!"
End If
End Sub

4. On the Menu bar, choose View | Object, to return to th
UserForm.



--
MDubbelboe
-----------------------------------------------------------------------
MDubbelboer's Profile: http://www.excelforum.com/member.php...fo&userid=3633
View this thread: http://www.excelforum.com/showthread.php?threadid=56233


Hammer1947

Accidentally close user form_how to open
 
"MDubbelboer"
I entered the code as directed and clicked on the "X" and it closed. The
form should take on the screen until the program closes. Another words the
opening and closing of the program dictates the open and close of the form.
Also I don't have Object on the menu bar under View. I'm using 2003 Office.
Don't need the Msgbox since the buttons control only the printing.

Gary
"MDubbelboer" wrote:


Hammer1947 Wrote:
Thanks Leith,
I don't want to have to Alt F8 to display the form. The form needs to
be
loaded and visible at all times while the excel program is running. The
only
thing I was concerned about was the close "X". If I accidentally click
the
close "X" the form goes away and I can't get it back. Ideally would be
to get
rid of the "X" button since I never want to close it during the running
of
the program. This form has buttons on it that are always used during
the
program.

gary


from: http://www.contextures.com/xlUserForm01.html

To prevent users from closing the form by clicking the X button:

1. Right-click on an empty part of the UserForm
2. Choose View | Code
3. Scroll to the bottom of the existing code, and enter the
following code:

Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please use the button!"
End If
End Sub

4. On the Menu bar, choose View | Object, to return to the
UserForm.




--
MDubbelboer
------------------------------------------------------------------------
MDubbelboer's Profile: http://www.excelforum.com/member.php...o&userid=36330
View this thread: http://www.excelforum.com/showthread...hreadid=562333



Hammer1947

Accidentally close user form_how to open
 
Success! Got the code to work thanks, M

gary

"MDubbelboer" wrote:


Hammer1947 Wrote:
Thanks Leith,
I don't want to have to Alt F8 to display the form. The form needs to
be
loaded and visible at all times while the excel program is running. The
only
thing I was concerned about was the close "X". If I accidentally click
the
close "X" the form goes away and I can't get it back. Ideally would be
to get
rid of the "X" button since I never want to close it during the running
of
the program. This form has buttons on it that are always used during
the
program.

gary


from: http://www.contextures.com/xlUserForm01.html

To prevent users from closing the form by clicking the X button:

1. Right-click on an empty part of the UserForm
2. Choose View | Code
3. Scroll to the bottom of the existing code, and enter the
following code:

Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please use the button!"
End If
End Sub

4. On the Menu bar, choose View | Object, to return to the
UserForm.




--
MDubbelboer
------------------------------------------------------------------------
MDubbelboer's Profile: http://www.excelforum.com/member.php...o&userid=36330
View this thread: http://www.excelforum.com/showthread...hreadid=562333




All times are GMT +1. The time now is 12:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com