Hollywood
New member
- Joined
- Sep 10, 2004
- Messages
- 1
I have accomplished the feat of opening a Excel spreadsheet and now I want to save that sheet as a .csv. I do not want to simply rename the extension, but rather save it as a comma-separated file so I can parse the data inside it. One other twist it that I have to run this on systems with\without Excel installed and also different versions. (2000\2002\2003)
Heres what I have:
Dim Excelapp As Excel.Application
Dim ExcelWS As Excel.Worksheet This is the sheet
Excelapp.Workbooks.Open(FileName:=strXLSPath)
Check for later versions.
If Val(Excelapp.Application.Version) >= 8 Then
ExcelWS = Excelapp.ActiveSheet
Else
ExcelWS = Excelapp
End If
Open specified worksheet
ExcelWS = Excelapp.Worksheets(2)
ExcelWS.SaveAs(strPath & strCSVFile, Excel.XlFileFormat.xlCSV)
Close without saving
Excelapp.ActiveWorkbook.Close(False)
Excelapp.Quit()
ExcelWS = Nothing
Excelapp = Nothing
The bold code works on 2002 versions, but not on other versions. Is there an equivilent that will work on all versions?
TIA,
Hollywood
Heres what I have:
Dim Excelapp As Excel.Application
Dim ExcelWS As Excel.Worksheet This is the sheet
Excelapp.Workbooks.Open(FileName:=strXLSPath)
Check for later versions.
If Val(Excelapp.Application.Version) >= 8 Then
ExcelWS = Excelapp.ActiveSheet
Else
ExcelWS = Excelapp
End If
Open specified worksheet
ExcelWS = Excelapp.Worksheets(2)
ExcelWS.SaveAs(strPath & strCSVFile, Excel.XlFileFormat.xlCSV)
Close without saving
Excelapp.ActiveWorkbook.Close(False)
Excelapp.Quit()
ExcelWS = Nothing
Excelapp = Nothing
The bold code works on 2002 versions, but not on other versions. Is there an equivilent that will work on all versions?
TIA,
Hollywood