Skip to content

Instantly share code, notes, and snippets.

@thomasleveil
Created July 25, 2018 09:45
Show Gist options
  • Save thomasleveil/a2c405e7fdf818aebdbb93dbd0d4e0cc to your computer and use it in GitHub Desktop.
Save thomasleveil/a2c405e7fdf818aebdbb93dbd0d4e0cc to your computer and use it in GitHub Desktop.
VBS script to convert an excel file to csv
if WScript.Arguments.Count < 1 Then
WScript.Echo "Please specify the source files. Usage: ExcelToCsv <xls/xlsx source file>"
Wscript.Quit
End If
csv_format = 6
Set objFSO = CreateObject("Scripting.FileSystemObject")
src_file = objFSO.GetAbsolutePathName(Wscript.Arguments.Item(0))
' dest_file = objFSO.GetAbsolutePathName(WScript.Arguments.Item(1))
dest_file = Replace(Replace(src_file,".xlsx",".csv"),".xls",".csv")
Dim oExcel
Set oExcel = CreateObject("Excel.Application")
Dim oBook
Set oBook = oExcel.Workbooks.Open(src_file)
oBook.SaveAs dest_file, csv_format
oBook.Close False
oExcel.Quit
@osaraivamatheus
Copy link

How can I set ";" as separator?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment