Juan,
This is just another event so paste it in the form module at the end.
But be careful, the code provided will never let you close the form. There
are 4 close generating events, and you should only cancel at most 3. In your
case, I think you only need to use one, like so
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Select Case CloseMode
Case vbFormControlMenu: '0 user chosen Close command from Control
menu on the UserForm
Cancel = -1
Case vbFormCode: '1 unload statement is invoked from code.
Case vbAppWindows: '2 current Windows operating environment
session is ending.
Case vbAppTaskManager: '3 Windows Task Manager closing the
application
End Select
End Sub
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Juan" wrote in message
...
Hello,
where exactly do i do this?
I have a button, when I click this it opens the Userfrom.
In the button I have the following:
Private Sub CommandButton2_Click()
UserForm1.Show
End Sub
I tried to incorporate your code but doesn't open the
form.
Please advise thanks,
juan
-----Original Message-----
put this in your code
Private Sub UserForm_QueryClose(Cancel As Integer,
CloseMode As
Integer)
Cancel = 1
End Sub
this will stop the user from closing the userform
Phonio
---
Message posted from http://www.ExcelForum.com/
.