PDA

View Full Version : Solved: Don't Allow Save On Close



CreganTur
04-11-2008, 06:13 AM
I've been doing some research on this, but so far haven't come up with anything that works.

Is there any way to disable the save prompt when a user closes a document? I tried adding this:
Application.Quit SaveChanges:=wdDoNotSaveChanges
to the On Close event, but that causes an error message that says: "You cannot close Microsoft Office Word because a dialog box is open." I know the reason for this is that the save prompt is triggered at the same time as my Quit code.

My desired result would be for, when the user closes the document, it would close without saving and without kicking off the save prompt.

Any ideas?:dunno

chandansify
04-11-2008, 07:24 AM
What I think here, You should use

ActiveDocument.Saved = True

to set save flag of the document and it will not prompt save on close.

Try this if it works for you.

CreganTur
04-11-2008, 07:43 AM
That worked perfectly, thanks!

Just a note on setting save flags:

from what I noticed you have to set the save flag after all changes to the document for it to work, otherwise if anything changes the document after you set the save flag it will be reset and you'll get the save prompt on close.

For msyelf I just set the save = true as the very last step in my on Close event.

chandansify
04-11-2008, 07:45 AM
That worked perfectly, thanks!

Just a note on setting save flags:

from what I noticed you have to set the save flag after all changes to the document for it to work, otherwise if anything changes the document after you set the save flag it will be reset and you'll get the save prompt on close.

For msyelf I just set the save = true as the very last step in my on Close event.



You got it all..

Cheers..

lucas
04-11-2008, 10:37 AM
If you would research templates you could avoid this problem alltogether. If I understand, you want to open this file and make some changes and then what do you do......make a copy? Why would you want to close it without making changes.

With a template you clone the template....make your changes and save the clone.....with changes......template is unaffected for the next run.....

I may not understand what you are trying to do but this sounds like the only logical reason for what you are doing here.

mdmackillop
04-11-2008, 10:50 AM
This won't prevent the user from saving the document at any other time. I go along with Steve on this one.

CreganTur
04-11-2008, 11:27 AM
With a template you clone the template....make your changes and save the clone.....with changes......template is unaffected for the next run.....


This document needs to be housed on a shared network drive. Is there a way to setup a template so that it can be run from the network drive, or would I have to send the template to the templates folder of every user who would need it?

fumei
04-11-2008, 11:53 AM
"Is there a way to setup a template so that it can be run from the network drive"

Yes. Put the .dot file on the network drive. Make sure users have Read access. Done.