Convert from XLS to CSV using VBScript

wiere's Avatar, Join Date: Jun 2009
Newbie Member
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
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
How do I drag the files to VBS.
0
wiere's Avatar, Join Date: Jun 2009
Newbie Member
Sorry i didnt explain. Save this vbs script and drag the XLS files onto it in windows explorer.
0
wiere's Avatar, Join Date: Jun 2009
Newbie Member
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
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Added the first line to the code above.
0
Click_talk's Avatar
Newbie Member
Hi,

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

PLease help.

Thanks,
James