randyzapata
Mar 25 2005, 02:53 PM
I am using the following to prevent a user from closing a form but I also want prevent a user from saving or closing excel except if they use my user form buttons. Is this possible?
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Application.DisplayAlerts = True
MsgBox "Sorry, you may not close the form like that!"
Cancel = True
Application.DisplayAlerts = False
End If
End Sub
KingMartin
Mar 25 2005, 03:04 PM
Hi Randy,
showing the form as modal,
Userform1.Show vbModal
could help.
Martin
randyzapata
Mar 25 2005, 03:14 PM
but how do I disable the user from saving or closing excel when I close or hide the user form
KingMartin
Mar 25 2005, 04:10 PM
You'll need API calls for true disabling of the close button in the application menu.
I attached an example of a pure VBA approach, see if it helps...
Martin
randyzapata
Mar 25 2005, 10:35 PM
That was just what I was trying to do

Thanks again
KingMartin
Mar 26 2005, 05:40 PM
Glad to help,
you're welcome

Martin
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.