Help with SaveAs

G

Glen Mettler

Using Excel 2002
I have the following macro to save a worksheet as a CSV file:
For s = 2 To 9
Sheets(s).Select
sheetName = ActiveSheet.Name
ActiveSheet.Copy

ActiveWorkbook.SaveAs filename:=csv_path & "\" & sheetName & ".csv",
FileFormat:=xlCSV
ActiveWorkbook.Close Savechanges:=False
Next

I get the message that the CSV file already exists - do I want to save
anyway for each sheet it attempts to create.

How can I code it to "overwrite" so I don't get that message? I can't seem
to find anything in the help file that tells me that.

Thanks,
Glen
 
N

Nigel

Place the following around your save

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs filename:=csv_path & "\" & sheetName &
".csv",FileFormat:=xlCSV
Application.DisplayAlerts = True

HTP
Cheers
Nigel
 

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