Wow, thanks for that! but, that wasn't what I needed. I need to run this as part of a batch file.
I found the following code to work great: Convert an xls file to CSV
I run it like so: wscript xls2cvs.vbs C:\SourceFile.xls C:\DestFile.csv
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)) Dim oSheet If oBook.Sheets.count = 1 Then 'save a single sheet oBook.SaveAs WScript.Arguments.Item(1), 6 else 'save multiple sheets i=1 aname=split(Wscript.Arguments.Item(1),".",-1,1) For Each oSheet In oBook.WorkSheets fname = aname(0) & "_sheet" & Cstr(i) oSheet.SaveAs fname, 6 i=i+1 Next End If oBook.Close True oExcel.Quit WScript.Quit set oSheet = Nothing set oBook = Nothing set oExcel = Nothing




Reply With Quote

Bookmarks