Detect if changes made inside Autoclose macro?

D

Dorian

I'm creating a new version of a document each time it is closed. I do this
by using the autoclose macro. However, I'd really like to avoid creating a
new version if no changes have been made. is there any way to detect this
inside the autoclose macro?
I'm not using the 'track changes' feature and have no plans to.
Thanks for any advice.

-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
G

Gordon Bentley-Mix

Dorian,

Try evaluating the .Saved property of the document in your AutoClose macro.
If the document has NOT been modified since the last time it was saved, the
..Saved property will be 'True'. Otherwise, it will be 'False'.
--
Cheers!

Gordon Bentley-Mix
Word MVP

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
J

Jay Freedman

I'm creating a new version of a document each time it is closed. I do this
by using the autoclose macro. However, I'd really like to avoid creating a
new version if no changes have been made. is there any way to detect this
inside the autoclose macro?
I'm not using the 'track changes' feature and have no plans to.
Thanks for any advice.

-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".

This can be quite a difficult question.

Your macro can easily tell whether the document has been changed since the last
time it was saved by looking at the value of ActiveDocument.Saved. It will be
false if there are any unsaved changes.

However, if ActiveDocument.Saved is True, you don't know whether that's because
the document hasn't been changed since it was opened, or because changes were
made and the document was saved during the current session.

Here's a possible scheme: Write an AutoOpen macro that creates a text file in
the same folder with the document file, and puts the current date/time in that
text file. In the AutoClose macro, compare the modification date/time of the
document file to the date/time in the text file. If the document file is later,
then you know the document has been saved during the current session (and since
Word doesn't actually save unless the file contains a change, you know there's
at least one change).
 

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