Solved

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

Posted on 2014-02-13
4
818 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 56

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 70

Expert Comment

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

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

626 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