View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Paul James[_3_] Paul James[_3_] is offline
external usenet poster
 
Posts: 58
Default the file already exists - do you want to replace the existing file?

I've got a VBA procedure that saves a record to disk using
Application.GetSaveAsFilename. However, if the file it's trying to save
already exists, the Windows API generates the above message, and the user's
only option is to either replace the existing file, or manually rename the
existing file in the File Save As.

What I'd really like to do is modify the code so that when it's run, it
takes care of renaming the existing file (if it exists) by adding a "1" to
the end of the filename, then saving the file in memory with the original
name, all without requiring the user to do anything. For simplicity, I'd be
happy to keep appending the character "1" to the end of any previously
renamed files in case this operation is performed multiple times, instead of
trying to increase the appended digit by 1 each time.

Is there any VBA code I can use to accomplish this?

Thanks in advance.

Paul