Created
July 25, 2018 09:45
-
-
Save thomasleveil/a2c405e7fdf818aebdbb93dbd0d4e0cc to your computer and use it in GitHub Desktop.
VBS script to convert an excel file to csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can I set ";" as separator?