Convert from XLS to CSV using VBScript

Newbie Member
25Jun2009,16:13   #1
wiere's Avatar
Realised used this site quite a lot without ever giving back to it, so i thought i'd change that.

This script is nice and simple way of converting xls to csv simply drag the files onto the vbs to use.

Code:
Set objArgs = WScript.Arguments
For I = 0 to objArgs.Count - 1

    FullName = objArgs(I)
    FileName = Left(objArgs(I), InstrRev(objArgs(I), ".") )

    Set objExcel = CreateObject("Excel.application")
    set objExcelBook = objExcel.Workbooks.Open(FullName)

    objExcel.application.visible=false
    objExcel.application.displayalerts=false

    objExcelBook.SaveAs FileName & "csv", 23

    objExcel.Application.Quit
    objExcel.Quit   

    Set objExcel = Nothing
    set objExcelBook = Nothing

Next
Go4Expert Founder
25Jun2009,16:43   #2
shabbir's Avatar
How do I drag the files to VBS.
Newbie Member
25Jun2009,17:06   #3
wiere's Avatar
Sorry i didnt explain. Save this vbs script and drag the XLS files onto it in windows explorer.
Newbie Member
25Jun2009,17:25   #4
wiere's Avatar
I'm sorry i missed the top line of code out. This needs to be the first line:

Code:
 Set objArgs = WScript.Arguments
should work now
Go4Expert Founder
25Jun2009,19:40   #5
shabbir's Avatar
Added the first line to the code above.
Newbie Member
8Jul2010,10:45   #6
Click_talk's Avatar
Hi,

How to make it to work for Multiple Tabl in the same Excel file.

PLease help.

Thanks,
James