3

I have Excel 2010.

Found this: Batch XLS to CSV Converter

But I actually need to export all excel worksheets as individual CSV files. Not sure if it works that way. Also if I were to use the above method, how do I actually use a VB script? (not familiar with programming)

AKA
  • 31

1 Answers1

2

Here is a cleaned-up version of the script from the post to which you linked:

Option Explicit

Const xlXMLSpreadsheet = 46
Const xlCSV = 6

Dim xl, wb, ws

Dim args : Set args = WScript.Arguments

If args.Count <> 1 Then
  WScript.Echo "Syntax: cscript " & WScript.ScriptName & " filename"
  WScript.Quit(1)
End If

Set xl = CreateObject("Excel.Application")
Set wb = xl.Workbooks.Open(args(0))

xl.DisplayAlerts = False
For Each ws In wb.Worksheets
 ws.activate
 wb.SaveAs CreateObject("Scripting.FileSystemObject").GetBaseName(args(0)) _
   & "_" & Replace(ws.Name, " ", "_") & ".csv", xlCSV
Next
xl.DisplayAlerts = True

wb.Close False
xl.Quit
WScript.Quit

It should do what you want. You call it like this from a command prompt:

cscript SCRIPT.vbs INPUT.xls

It creates output files INPUT_SHEETNAME.csv.