I'm trying to create an overwrite save command within MS Excel 2003.

I'm saving the active work book as a new file:

ActiveWorkbook.SaveAs FileName:="c:\Test\testfile.csv"

I need to run this macro on a regular basis and sometimes the file will be already held in the location above and sometimes it won't be.

When I run it, if the file already exists it prompts me to overwrite it, but I want it to do this it automatically rather than prompt me.

I've tried sticking a SaveChanges:=True at the end on the command but it doesn't like this at all.....!!

Can anybody advise if this can be done within an excell macro and how, I'm sure it can be, but I just can't figure it out.

Here is the way to overcome that:

Sub Open_n_Save_as_Text()
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="c:\test\testfile.csv", FileFormat:=xlCSV
Application.DisplayAlerts = True
End Sub

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.