Batch Convert CSV to XLS

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi Everyone!

Can anyone show me the code for a macro that will format a folder full of
CSV files to XLS files automatically.

Thanks
Dave
 
Dave,

Try the macro below. Just change the path to your folder....

HTH,
Bernie
MS Excel MVP


Sub TransformCSVToXls()
Application.DisplayAlerts = False
myFile = ActiveWorkbook.Name
myPath = "C:\Documents and Settings\DEITBE\My Documents\Excel\Delete These\"
WorkFile = Dir(myPath & "*.CSV")

Do While WorkFile <> ""
Application.StatusBar = "Now working on " & WorkFile
Workbooks.Open FileName:=myPath & WorkFile
MsgBox ActiveWorkbook.Name
ActiveWorkbook.SaveAs FileName:=myPath & _
Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4), FileFormat:=xlNormal
ActiveWorkbook.Close
Windows(myFile).Activate
WorkFile = Dir()
Loop

Application.StatusBar = False

End Sub
 
Back
Top