How to overwrite existing file without prompting?


Posted by Dennis on December 14, 2001 11:07 AM


I keep getting a message box asking if I want to overwrite the existing file. Is there a way I can modify my code so that the message doesn't appear and the file (Test.txt) is automatically overwriten?

Workbooks.Open Filename:="C:\Test.xls"
ActiveWorkbook.SaveAs Filename:="C:\Test.txt", _
FileFormat:=xlText, CreateBackup:=False



Posted by MrExcel on December 14, 2001 11:26 AM

Use Application.DisplayAlerts

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs (etc.)
Application.DisplayAlerts = True