Checking for initial save of a file

  • Thread starter christophercbrewster via OfficeKB.com
  • Start date
C

christophercbrewster via OfficeKB.com

I need to check that a file has been saved for the first time and given a
name. The ActiveDocument.Saved property is too restrictive-- I don't want to
prompt the user to do anything if the file has had the initial save. Is there
a way to detect this?

--
Christopher Brewster
Lockheed Martin, Eagan MN

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200901/1
 
C

christophercbrewster via OfficeKB.com

I found an acceptable solution, though someone here might know a better one.

If ActiveDocument.Path = "" Then
MsgBox "Please save your document."
On Error Resume Next ' Current Ppt file name if set
ActiveDocument.Save
If Err <> 0 Then Exit Sub
End If
 
G

Graham Mayor

Simply save the document. If the document has not been saved you will be
prompted for a name. If it has, nothing visible happens.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

christophercbrewster via OfficeKB.com

I don't want to do it that way because for other the people using this,
having an automatic save isn't really appropriate at this point. My code
using ActiveDocument.path as the condition seems to do the trick.
 
G

Graham Mayor

If a document has not been saved the path length will be 0 so

With ActiveDocument
If Len(.Path) = 0 Then 'Document is not saved
.Save 'So save it
End If
End With


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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