batch CSV to Excel

Hi,

Is there a automated way to convert files in a folder from CSV to Excel?  thanks
mcrmgAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Wayne88Commented:
If you open the CSV files directly in Excel, do they open up correctly or does it need to be modified?  If this is ok then you can just rename all csv to xls via command prompt.

ren *.csh *.xls
0
mcrmgAuthor Commented:
They need to be modified.. It gas "|" as delimiter...thx
0
Wayne88Commented:
This tool supports custom delimiter.  It may be a use to you:

http://www.dbf2002.com/csv-converter/convert-csv-to-xls.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bill PrewCommented:
Here is a VBS script approach that will get it done.  It assumes you have Excel installed on the computer you run this on though, no way around that.  Save this as a VBS file, and then run like this, passing it the path to the folder with the CSV files in it to process.  For each one the script will create an XLS version in the same folder.  Sample command line:

cscript EE28703584.vbs C:\Files

'Constants
Const cExcel8 = 56

strExcel = "xls"
strCSV = "csv"

' Set up filesystem object for usage
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Get folder name to process off the command line, make sure it's valid
If (WScript.Arguments.Count > 0) Then
    strFolder = Wscript.Arguments(0)
    If Not objFSO.FolderExists(strFolder) Then
        WScript.StdErr.WriteLine "Specified folder does not exist."
        WScript.Quit
    End If
Else
    WScript.StdErr.WriteLine "No folder name specified to process."
    WScript.Quit
End If

' Access the folder to process
Set objFolder = objFSO.GetFolder(strFolder)

' Load Excel for conversions
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.DisplayAlerts = False

' Process files
For Each objFile In objFolder.Files
   strPath = objFile.Path
   ' Only convert CSV files
   If LCase(objFSO.GetExtensionName(strPath)) = LCase(strCSV) Then
      ' Load into Excel and save as native Excel file
      Set objWorkbook = objExcel.Workbooks.Open(strPath, False, True)
      objWorkbook.SaveAs Replace(strPath, strCSV, strExcel), cExcel8
      objWorkbook.Close False
      Set objWorkbook = Nothing
   End If
Next

'Wrap up
objExcel.Quit
Set objExcel = Nothing
Set objFSO = Nothing

Open in new window

~bp
0
mcrmgAuthor Commented:
Hi, bill,

Thanks for the script, but it looks like it does not modify the delimiter, or maybe I am not using it correctly. Thx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.