Determining if a document is a file

B

Bob

I don't want to run my macro if a document is "new", i.e., has never been
saved as a file. Checking activedocument.saved doesn't work, because if
it's a new, unaltered document, ad.saved is True.

Looking through the document properties, I've found that the following seem
to indicate a never-saved document:

ad.path = ""
right(ad.fullname,3)<>"doc"

Are there cases where the above checks would not work? Is there another
property I'm missing?

Thanks,
Bob
 
K

Karl E. Peterson

Bob said:
I don't want to run my macro if a document is "new", i.e., has never
been saved as a file. Checking activedocument.saved doesn't work,
because if it's a new, unaltered document, ad.saved is True.

Looking through the document properties, I've found that the
following seem to indicate a never-saved document:

ad.path = ""
right(ad.fullname,3)<>"doc"

Are there cases where the above checks would not work? Is there
another property I'm missing?

What if the user didn't use "DOC" as the extension? Lots of old WordPerfect
folks never really adapted to that. <g>
 
H

Helmut Weber

Hi Bob,
ad.path = ""

That's sufficient, IMHO.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
J

Jay Freedman

What if the user didn't use "DOC" as the extension? Lots of old WordPerfect
folks never really adapted to that. <g>

The test for .Path = "" does work. As Karl says, the extension isn't
reliable.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 

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