"Go ahead and replace file" command?

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
 
T

Tom Ogilvy

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
 
E

Ed

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
 

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