convert multiple excel spreadsheets to csv
Can someone please give a hint on how to convert multiple excel worksheets from a single excel workbook.
I have a piece of code that will convert the first worksheet in the workbook but no more than that:
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
Is it possible to do more than one worksheet?
Any help on this would be greatly appreciated.
Re: convert multiple excel spreadsheets to csv
Try something like this (untested):
Code:
For Each objWorksheet In objExcelBook.Worksheets
objWorksheet.Copy
objExcel.ActiveWorkbook.SaveAs "theFileName.csv", 23
objExcel.ActiveWorkbook.Close False
Next
Change "theFileName.csv" to the required file name, maybe including the sheet name.