That should be as easy as
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
'Prevent user from closing with the Close box in the title bar.
If CloseMode < 1 Then Cancel = 1
cmdExit
End Sub
If cmdExiit is a button on the form, you would call the Click event and it
would then be
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
'Prevent user from closing with the Close box in the title bar.
If CloseMode < 1 Then Cancel = 1
cmdExit_Click
End Sub
Either of these work?
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"D.S." wrote in message
...
I would like to run my "cmdExit" procedure here, if the user clicks the
close button, but I haven't had any luck. I get a syntax error. Can a
procedure be ran from here?
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
'Prevent user from closing with the Close box in the title bar.
If CloseMode < 1 Then Cancel = 1
' < I would rather call my cmdExit procedure here, and omit the
following line
frmDataEntry.Caption = "The Close box has been de-activated! Please
click the exit button below!"
End Sub
D.S.
"Chip Pearson" wrote in message
...
DS,
You can use the QueryClose event procedure to catch the form's
closing via the 'X' button.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"D.S." wrote in message
...
I would like to prevent the user from closing a userform by
clicking the 'X'
on the right side of the titlebar. I need to force closure by
using a
command button, and running an exit procedure. Is there a
property setting
that will prevent this / or run the exit procedure when the 'X'
is clicked?
D.S.