VBScript to convert XML to CSV

stackoverflow.com

 

Dim xlApp, xlWkb, SourceFolder,TargetFolder,file
Set xlApp = CreateObject("excel.application")
Set fs = CreateObject("Scripting.FileSystemObject")

Const xlNormal=1
Const xlCSV=6

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 & "\" & BaseName & ".csv"
xlWkb.SaveAs FullTargetPath, xlCSV, , , , , , 2
xlWkb.Saved = True
xlWkb.close
file.Delete
next

Set xlWkb = Nothing
Set xlApp = Nothing
Set fs = Nothing

広告を非表示にする