Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Duplicate Filename Error

Status
Not open for further replies.

mattygriff

Programmer
May 14, 2001
350
GB
I have an application which automatically generates a file name based on report number and a couple of other parameters. Occasionally, this throws up an issue where the filename generated has already been created and Excel asks whether the user wants to overwrite the existing file.

If the user selects Yes then everything works fine and the file is saved but if they select No then I get an error that "Method 'SaveAs' of object '_Workbook' failed".

Is there a way that I can check whether the generated filename has already been created? The files are always saved in the same directory, if that helps.

TIA.
 
Have a look at the Dir function.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV - managed to get sorted using the FileSystemObject approach.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top