Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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)

share|improve this question
    
using Windows 7 –  AKA Sep 20 '12 at 23:35
    
Just use COM from Python to spit them out. –  Ignacio Vazquez-Abrams Sep 20 '12 at 23:44
    
To use Excel's VBA capabilities, press Alt + F11. Then go to 'Insert' -> 'Module'. Your code goes in the text window that opens. –  Excellll Sep 21 '12 at 13:29

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.