View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Remove close Button

Don't remove it, just trap the click.

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
MsgBox "Close mode is " & CloseMode
End Sub


from help


Occurs before a UserForm closes.


Syntax


Private Sub UserForm_QueryClose(cancel As Integer, closemode As Integer)


The QueryClose event syntax has these parts:


Part Description
cancel An integer. Setting this argument to any value other than 0
stops the QueryClose event in all loaded user forms and prevents the
UserForm and application from closing.
closemode A value or constant indicating the cause of the QueryClose
event.


Return Values


The closemode argument returns the following values:


Constant Value Description
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.


These constants are listed in the Visual Basic for Applications object
library in the Object Browser. Note that vbFormMDIForm is also specified in
the Object Browser, but is not yet supported.


Remarks


This event is typically used to make sure there are no unfinished tasks in
the user forms included in an application before that application closes.
For example, if a user hasn't saved new data in any UserForm, the
application can prompt the user to save the data.


When an application closes, you can use the QueryClose event procedure to
set the Cancel property to True, stopping the closing process.


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"jk" wrote in message
...
How does one remove the upper right hand close button on the form? I have

a
form that opens on work book open and i want to remove that option from

the
user.