amending the behaviour of the close button

M

matt101

Hello,

I have a macro which allows the user to save a document under a name
they specify by pressing a button. I want to remove all other methods
of saving, so while its easy to remove the buttons on the File menu and
Standard toolbar, is it possible to have the Close button in the top
right corner to display the same save option as in the following macro?
If so, what should be added to the macro?

Thanks in advance,

Sub CreateBackup()
ChangeFileOpenDirectory _
"\\servername\folderpath"
strDocName = InputBox("Enter the name of your document.")
ActiveDocument.SaveAs FileName:=strDocName, _
FileFormat:=wdFormatDocument _
, LockComments:=False, Password:="", AddToRecentFiles:=True, _
WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False,
SaveAsAOCELetter:= _
False
End Sub
 
E

Ed

Hi matt101,

You might be able to do that but I think it depends upon your version of Word.

Some versions (e.g. 2003) allow you to get at the event that happens when a
document is about to close (the DocumentBeforeClose event) and if you can
access that event you can arrange for your macro code to run.

For details of how to do this sort of thing, check this site:
http://www.word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm

If you get stuck, post back with your version of Word and someone may be
able to assist.

Regards.

Ed
 
M

matt101

Thanks Ed!

I will take a look.

Ed;270641 said:
Hi matt101,

You might be able to do that but I think it depends upon your version
of Word.

Some versions (e.g. 2003) allow you to get at the event that happens
when a
document is about to close (the DocumentBeforeClose event) and if you
can
access that event you can arrange for your macro code to run.

For details of how to do this sort of thing, check this site:
http://www.word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm

If you get stuck, post back with your version of Word and someone may
be
able to assist.

Regards.

Ed

:
-

Hello,

I have a macro which allows the user to save a document under a name
they specify by pressing a button. I want to remove all other methods
of saving, so while its easy to remove the buttons on the File menu
and
Standard toolbar, is it possible to have the Close button in the top
right corner to display the same save option as in the following
macro?
If so, what should be added to the macro?

Thanks in advance,

Sub CreateBackup()
ChangeFileOpenDirectory _
"\\servername\folderpath"
strDocName = InputBox("Enter the name of your document.")
ActiveDocument.SaveAs FileName:=strDocName, _
FileFormat:=wdFormatDocument _
, LockComments:=False, Password:="", AddToRecentFiles:=True, _
WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False,
SaveAsAOCELetter:= _
False
End Sub
 

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