title: VBScript to convert XML to CSV
body: <p>I have a VBScript that converts any XML file in a folder to XLS and then deletes the XML files - all works fine.</p>
  
  <p>However, I know need to convert the XMLs to CSV rather than XLS.</p>
  
  <p>What do I need to change in the script to allow this? Simply changing the extension of the resulting file(s) obviously doesn't work.</p>
  
  <pre class="lang-vb prettyprint-override"><code>Dim xlApp, xlWkb, SourceFolder,TargetFolder,file
  Set xlApp = CreateObject("excel.application")
  Set fs = CreateObject("Scripting.FileSystemObject")
  
  Const xlNormal=1
  
  SourceFolder="c:\xml-to-xls\xml"
  TargetFolder="c:\xml-to-xls\xls"
  
  xlApp.Visible = false
  
  for each file in fs.GetFolder(SourceFolder).files
    Set xlWkb = xlApp.Workbooks.Open(file)
    BaseName= fs.getbasename(file)
    FullTargetPath=TargetFolder &amp; "\" &amp; BaseName &amp; ".xls"
    xlWkb.SaveAs FullTargetPath, xlNormal
    xlWkb.close
  next
  
  fs.DeleteFile("C:\xml-to-xls\xml\*.xml")
  
  Set xlWkb = Nothing
  Set xlApp = Nothing
  Set fs = Nothing
  </code></pre>
  
  <p>Thanks</p>