"Go ahead and replace file" command?

  • Thread starter Thread starter Ed
  • Start date Start date
E

Ed

I need to create a file and SaveAs a file with the same name. Will the
Alerts = False automatically tell it "Yes, replace the other file with the
same name"? Or is there another line I should add to the SaveAs code to
tell Excel to overwrite and replace the existing file?

Thanks.
Ed
 
Yes,
Application.DisplayAlerts = False

will allow you to overwrite the file without prompt.

Another approach is to Kill any existing file before doing the saveas

fName = "C:\Myfolder\Myfile.xls"
On Error Resume Next
Kill fName
On Error goto 0
Thisworkbook.SaveAs fName
 
Thanks, Tom. I appreciate the help.

Ed

Tom Ogilvy said:
Yes,
Application.DisplayAlerts = False

will allow you to overwrite the file without prompt.

Another approach is to Kill any existing file before doing the saveas

fName = "C:\Myfolder\Myfile.xls"
On Error Resume Next
Kill fName
On Error goto 0
Thisworkbook.SaveAs fName
 
Back
Top