Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable the Close (X) button in a Word Document

Status
Not open for further replies.

nochoice

Programmer
Jun 17, 2003
72
0
0
CA
I would like to take thread707-567962 a little further.

Is it possible to disable the close button on a word document?

The reason I would like this is, there is a Macro I want to run before I exit my Word documents and by force of habit, I frequently hit the (x) and click save. I want to disable this.

Or maybe I need to reprogram my brain, but I think it will be easier to disable the close button.

Cheers,
NoChoice
 
Hi nochoice,

I don't know if you can actually disable the [X], but if you set up an AutoExit (and/or an AutoClose) macro it will run when you exit Word (and/or a Document) and you should be able to do whatever you want to do. Look under "Auto Macros" in Help for details of how to set this up.

Enjoy,
Tony
 
Hi nochoise,

There is a way to prevent the user to use the [x] to close a form. Put this sub in your code:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)

If CloseMode = vbFormControlMenu Then
'show the user a message
MsgBox "Please use the [Exit] button to close this form.", vbOKOnly, "Attention!"
Cancel = True
End If

End Sub

Hope this helps.

Regards,
Unica
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top