title: Export each sheet to a separate csv file
body: <p>I need to programmaticaly via a VBA/VBS script export all worksheets (4 in total and I know the names) to worksheet named csv files in the same folder, without loading excel and running the macro manually.</p>
  
  <p>Ideally the script would take in the source filepath/filename.xls and the export filepath as command line arguments.</p>
  
  <p>I have read many Excel VBA scripts for doing just that within Excel and I have seen some for loading an excel workbook to export the first sheet. However when I try to blend the two I get this error:</p>
  
  <blockquote>
    <p>(1,12) Expected End of Statement</p>
  </blockquote>
  
  <pre><code>Dim source As Workbook
  Set source = Application.Workbooks.Open(WScript.Arguments.Item(0), ReadOnly:=True)
  For Each sheet In source.Sheets
  .SaveAs Filename:= WScript.Arguments.Item(1) &amp; Source.Sheets.Name, FileFormat:=xlCSV
  Next sheet
  wb.Close
  </code></pre>