userform titlebar and closing form
Use the form's QueryClose event. This has 2 arguments, Cancel and CloseMode.
CloseMode tells you where the close originates from.
vbFormControlMenu 0 The user has chosen the Close command from the
Control menu on the UserForm.
vbFormCode 1 The Unload statement is invoked from code.
vbAppWindows 2 The current Windows operating environment session is
ending.
vbAppTaskManager 3 The Windows Task Manager is closing the
application.
You can test this, and if it's from an unload statement, close else cancel
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Cancel = CloseMode < vbFormCode And CloseMode < vbAppWindows
End Sub
--
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 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.
|