command line to convert xls to txt (tab delimited)
OK, first of all, I've searched all over this forum and google and can not find an answer. I am not a vb developer, but searching (desperately at this point) for a way to convert an xls file to a tab delimited txt file via the command line.
I found this one that saves as a csv (comma delimited) but can't figure out how to change it to save as tab. I can't believe that it wouldnt be possible. Please HELP!! :D
Code:
if WScript.Arguments.Count < 2 Then
WScript.Echo "Error! Please specify the source path and the destination. Usage: XlsToCsv SourcePath.xls Destination.csv"
Wscript.Quit
End If
Dim oExcel
Set oExcel = CreateObject("Excel.Application")
Dim oBook
Set oBook = oExcel.Workbooks.Open(Wscript.Arguments.Item(0))
oBook.SaveAs WScript.Arguments.Item(1), 6
oBook.Close False
oExcel.Quit
WScript.Echo "Done"
Re: command line to convert xls to txt (tab delimited)
Welcome to the Forums.
Change the last argument of the saveas to specify text tab delimited.
Const xlText = -4158
Code:
oBook.SaveAs WScript.Arguments.Item(1), -4158
Re: command line to convert xls to txt (tab delimited)
If that value doesnt work then try either 20 or 21
Re: command line to convert xls to txt (tab delimited)
woohooo!!! thanks! I figured it was that easy but I couldnt find a legend for the saveas codes. thank you thank you thank you!
Re: command line to convert xls to txt (tab delimited)
Usually you can find most values by going into the desired Office application's Object Browser and searching for the constant and read its value.
If you have no clue what to search by then record a simple macro of you doing that task. Then check the macro code and evaluate the constant value in the Object Browser.
Ps, dont forget to mark the thread as Resolved from the Thread tools menu ;)
Re: command line to convert xls to txt (tab delimited)
How to convert xls to csv file saving the format of the each cell as 'Number'
because it should not convert to exponential. I am using below script
if WScript.Arguments.Count < 2 Then
WScript.Echo "Error! Please specify the source path and the destination. Usage: XlsToCsv SourcePath.xls Destination.csv"
Wscript.Quit
End If
Dim oExcel
Set oExcel = CreateObject("Excel.Application")
Dim oBook
Set oBook = oExcel.Workbooks.Open(Wscript.Arguments.Item(0))
oBook.SaveAs WScript.Arguments.Item(1), 6
oBook.Close False
oExcel.Quit
WScript.Echo "Done"