• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 521
  • Last Modified:

Check whether document has already been saved

Dear Experts:

I would like to get the following code snippet:

The macro should check ...
... whether the the current document has not been saved yet (ie. the document's name is just 'document1' or 'document2' etc.) .
If so the macro has to say so in a Msgbox and the macro is to exit.

If the document has already been saved the macro is to go on without coming up with any message.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
0
Andreas Hermle
Asked:
Andreas Hermle
  • 2
  • 2
1 Solution
 
GrahamSkanRetiredCommented:
Hi Andreas,

It might be best to test the Saved property. This is false between the time taht teh document is created or modified and it is saved.

Otherwise you can use this function.
Function IsSaved() As Boolean
    IsSaved = InStr(ActiveDocument.FullName, ".")
End Function

Open in new window

0
 
GrahamSkanRetiredCommented:
Oops. It looks as if my left hand was faster than my right in the middle of the second sentence. I've just re-installed my OS, and I haven't added the Firefox spell-checker yet.
0
 
Andreas HermleTeam leaderAuthor Commented:
Hi Graham,

thank you very much for your swift reply. Will try it out and let you know tomorrow.

Regards, Andreas
0
 
Andreas HermleTeam leaderAuthor Commented:
Works great, thank you Graham for the professional support. Regards, Andreas
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now