Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   Convert from XLS to CSV using VBScript (http://www.go4expert.com/forums/convert-xls-csv-using-vbscript-t18188/)

wiere 25Jun2009 16:13

Convert from XLS to CSV using VBScript
 
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


shabbir 25Jun2009 16:43

Re: Convert from XLS to CSV using VBScript
 
How do I drag the files to VBS.

wiere 25Jun2009 17:06

Re: Convert from XLS to CSV using VBScript
 
Sorry i didnt explain. Save this vbs script and drag the XLS files onto it in windows explorer.

wiere 25Jun2009 17:25

Re: Convert from XLS to CSV using VBScript
 
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

shabbir 25Jun2009 19:40

Re: Convert from XLS to CSV using VBScript
 
Added the first line to the code above.

Click_talk 8Jul2010 10:45

Re: Convert from XLS to CSV using VBScript
 
Hi,

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

PLease help.

Thanks,
James


All times are GMT +5.5. The time now is 10:16.