computing
  • 4

Solved Need Batch File To Convert Txt File To Xls

  • 4

comma separated txt file to convert into xls format

Share

1 Answer

  1. You will have to use VBS or some other means to access the Excel object. Here’s a very rudimentary VBS:

    ‘—————- begin vbscript “csv2xls.VBS”
    Set xl = WScript.CreateObject(“Excel.application”)

    xl.Visible = TRUE
    xl.displayalerts=False
    ‘paths must be FULLY QUALIFIED, esp. for INPUT files.

    set book=xl.workbooks
    source=wscript.arguments(0)
    ‘wscript.echo “trying to convert: [“+source+”]”
    dest=wscript.arguments(1)
    ‘wscript.echo “output going to: “+dest+”.xls”
    set f=book.open (source)
    f.saveas dest+”.xls”,35
    xl.quit
    ‘====== end vbscript

    example call from batch:
    cscript csv2xls c:\subd1\subd2\any.csv c:\converted\any

    my familiarity with the excel object is “slim to none”. You might want to do more research on your own to make things work like you want.
    Batch not tested, vbscript tested.

    message edited by nbrane

    • 0