How to disable the close 'x' button of word 2007 application

K

Kim

Hi,

Is there a way to disable the close button 'x' of the word 2007 application
itself (not a user form)? I have source code that worked for 2003 but it
seems like the source does not work anymore for word 2007. I appreciate any
help in advance.


-- Kim
 
D

Doug Robbins - Word MVP

It's always a good idea to give us the code that you have as it gives a
starting point to try and solve the issue.

The method in the article "A Pseudo DocumentBeforeClose Event" at:

http://www.word.mvps.org/FAQs/MacrosVBA/PseudoBeforeClose.htm

still works in Word 2007.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
K

Kim

Hi,

Thank you for replying my question. The source code that I use is below. It
works for Word 2003 but not for Word 2007:

Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long,
ByVal bRevert As Long) As Long
Public Declare Function GetActiveWindow Lib "user32" () As Long

Public Sub DisableControlExit()
Dim hMenu As Long
Dim Success As Long

'Get handle to system menu
hMenu = GetSystemMenu(GetActiveWindow, 0)

Success = EnableMenuItem(hMenu, SC_CLOSE, (MF_BYCOMMAND Or MF_DISABLED))

End Sub


The code is in a addin macro which gets loaded when editing other word
documents. I have looked at the link that you have suggested, but AutoClose
only worked when I opened and closed the macro, not when the macro was loaded
for other docs.
Is there any way to disable the 'x' button using window handler like the
source code above?

Thank you for your help.


-- mk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top