Save as Overwrite prompt

S

Steph

Sub Save_Book()
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=filepath & "VA05.xls"
Application.DisplayAlerts = True
End Sub

I want to save a file and automatically overwrite the existing file. I have
done this a thousand times, and it works fine. But now I am exporting a
report from an ERP system into Excel. When I run this code against the
resulting excel file, I get an error Method 'Display Alerts' of object
'Application' failed. Is there another way of Saving a file without being
prompted to overwrite or not? (I want the default to be Yes overwrite).
Thanks!
 
D

Dave Peterson

Maybe you could just delete the file (or at least try to):

on error resume next
kill filepath & "VA05.xls"
on error goto 0

activeworkbook.saveas filename:=filepath & "VA05.xls"

===
But I think I'd try to find out why that .displayalerts is breaking. I don't
recall ever seeing it break.
 

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