Solved

Can I change an Excel file to CSV (Comma Delimited) in a batch

Posted on 2014-02-13
4
765 Views
Last Modified: 2014-02-19
I have daily excel files that I would like to convert to CSV (Comma Delimited) with a batch.  When I manually convert the files I get Microsoft advising me some features are not compatible and do I want to keep the workbook in this format, so I click Yes and it converts to CSV.  Then when I try to close the book, it asks do I want to save changes made to CSV file.  I click no and it closes and I have my CSV file ready to go.  

I would like to create a batch to transfer the files to CSV (Comma Delimited) and close the files.  

Also, if possible I would like to add today's date on each file. Example 2014-02-13

File Names:
Daily Red Wagons
Daily Red Trains
Daily Blue Wagons
Daily Blue Trains

Thanks,
0
Comment
Question by:NNiicckk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 54

Expert Comment

by:Bill Prew
ID: 39855840
No way to do this in a pure batch (BAT) script solution.  Would a vbscript (VBS) script solution be acceptable?

~bp
0
 

Author Comment

by:NNiicckk
ID: 39856445
Yes, a VBS script would be acceptable.
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 39857502
PowerShell is another option. The code is nearly the same as in VBS.
0
 
LVL 54

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 39858018
Here's a VBS approach, let me know if it doesn't make sense.

Const cExcelCSV = 6

strDir = "B:\EE\EE28363894\Files\"
strExt = ".xls"
strCSV = ".csv"
arrList = Array("Daily Red Wagons","Daily Red Trains","Daily Blue Wagons","Daily Blue Trains")

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objExcel.DisplayAlerts = False

For Each strFile in arrList
   strPath = strDir & strFile & strExt
   If objFSO.FileExists(strPath) Then
      Set objWorkbook = objExcel.Workbooks.Open(strPath, False, True)
      objWorkbook.SaveAs Replace(strPath, strExt, strCSV), cExcelCSV
      objWorkbook.Close False
      Set objWorkbook = Nothing
   End If
Next

objExcel.Quit
Set objExcel = Nothing
Set objFSO = Nothing

Open in new window

~bp
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question