Prevent overwriting existing Word Docs

G

Guest

Hi
I wonder whether anyone can help me.
I'm using
DoCmd.SaveAs strDocumentPath & strDocumentName
to save a Word document that has been generated from my database
strDocumentName is based on the recipient name and the current date. At the
moment DoCmd.SaveAs is overwriting any existing files of the same name. How
do I invoke the normal Windows Save dialog box that warns the user that the
file already exists and allows them to change the name?

Failing that I suppose I need a way to notify the user that an existing file
is about to be overwritten.
Any help would be greatly appreciated.
Anna
 
D

Dan Artuso

Hi,
You can see if the code here is any help to you:
http://www.mvps.org/access/api/api0001.htm

or you can use the Dir function to see if the file exists.
Dir will return an empty string if the file does not exist so...

If Dir(strDocumentPath & strDocumentName) <> "" Then
'file exists
End If
 

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