macro to save a workbook as a .csv file type

  • Thread starter Thread starter carl
  • Start date Start date
C

carl

I have 10 workbooks (w/ 1 sheet in each) that I need to
save as a .csv file type. I also need to close each one
so that the newly created file can be imported into
another application. I tried writing a macro to do this
for me but could not get it to work too well - i was
getting prompted to many times.

Any thoughts on how I can do this without getting the
prompts ?
 
Try this

Select the files in GetOpenFilename

Sub test()
Dim FName As Variant
Dim N As Long
Dim Awb As Workbook
FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls", _
MultiSelect:=True)

If IsArray(FName) Then
Application.ScreenUpdating = False
For N = LBound(FName) To UBound(FName)
Set Awb = Workbooks.Open(FName(N))
Awb.SaveAs Filename:=Left(Awb.Name, Len(Awb.Name) - 4) & "CVS", FileFormat:=xlCSV
Awb.Close savechanges:=False
Next
Application.ScreenUpdating = True
End If
End Sub
 
Awb.SaveAs Filename:=Left(Awb.Name, Len(Awb.Name) - 4) & "CVS", FileFormat:=xlCSV

No problem but this is better ( I have CVS in the filename instead of CSV)

Awb.SaveAs Filename:=Left(Awb.Name, Len(Awb.Name) - 4) & "CSV", FileFormat:=xlCSV
 
Back
Top