PDA

View Full Version : CSV SaveAs, how to override are you sure questions



Annodomini2
03-08-2008, 10:50 AM
Hi all,

Had a search, but no luck so far.

When I SaveAs a file in CSV format it always asks me questions if I want to save in this format (lose excel stuff etc), is it possible to override these and force the save in VBA.

Thanks

Anno

lucas
03-08-2008, 12:34 PM
You don't say if you want a dialog to save the file in a different directory or if you are just saving one sheet but this should get you started. You must rename the csv file when the dialog comes up.

See if this works
Sub CSVSave()
Dim FileSaveName As String
FileSaveName = Application.GetSaveAsFilename( _
fileFilter:="CSV Files (*.csv), *.csv")
ActiveWorkbook.SaveAs Filename:=FileSaveName, FileFormat:=xlCSV
Application.DisplayAlerts = False
Application.Quit
End Sub

next
03-09-2008, 12:24 AM
i had the same question recently.
Use "Application.DisplayAlerts = False" in the beginning of you code, don't forget to re-enable it after you are done.