Word/Access VBA - SaveAs2 Method: How do I save as a different file name if file already exists?
Posted on 2013-01-26
RE: FileName Parameter
Microsoft MSDN Library states the following regarding the FileName parameter "The name for the document. The default is the current folder and file name. If the document has never been saved, the default name is used (for example, Doc1.doc). If a document with the specified file name already exists, the document is overwritten without prompting the user.
How do I save a file using a different name if that file name already exists?
I have an Access database that uses the Word.Application Object to generate multiple fax sheets from a table then saves each fax sheet into a folder. Sometimes the file names clash. If the file names clash then the previously saved fax sheet is overwritten. I would like to simulate the Windows Save As feature of appending a (1), (2), etc. to the file name if the file name already exists.
I generated VBA from Word using the macro recorder to save a document then pasted that vba into a button click event in Access. That's how I arrived at using the SaveAs2 method in the first place.