09-27-2004 03:30 AM
09-27-2004 05:23 AM
09-27-2004 05:45 AM
11-26-2008 12:11 PM
I'm having a bit of trouble with a simple task using the Excel OLE object in DIAdem.
I need to open a .csv (true comma separated) file to Excel
And then Save As .xls (true Excel 97-2003 format)
When I use the following code, the resulting file is named "result.xls" but is still comma separated inside. Is there a parameter for saving with a specified file format? I see there is such a parameter when the action is recorded in an Excel macro, but I couldn't figure out how to control that parameter in the OLE object.
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
oExcel.Workbooks.Open "C:\source.csv"
oExcel.ActiveWorkbook.SaveAs "C:\test.xls"
oExcel.ActiveWorkbook.save
oExcel.Application.quit
Using DIAdem 10.2/Excel 2007.
Thanks in advance for the help!
11-27-2008 01:47 AM
Hi Fitz
The easiest way to find out the parameters you need is to record a macro in Excel. The parameter you are looking for ist the second parameter in the "saveas" command.
The second parameter must be xlnormal or -4143. If you add the line autEdTypeLibAdd you can use the Excel constants by their name else you need the value.
' Microsoft Excel 11.0 Object Library
' C:\Programme\Microsoft Office\OFFICE11\EXCEL.EXE
Call AutEdTypeLibAdd("00020813-0000-0000-C000-000000000046", "1.5")
dim oexcel
Set oExcel = CreateObject("Excel.Application")oExcel.Visible = True
oExcel.Workbooks.Open "C:\source.csv"
oExcel.ActiveWorkbook.SaveAs "C:\test.xls" , xlnormal
'call oExcel.ActiveWorkbook.SaveAs ("C:\test.xls" ,-4143)
oExcel.ActiveWorkbook.save
oExcel.Application.Quit
Hope this helps
Winfried
Winfried
12-01-2008 03:57 PM
Winner,
Thank you for your fast reply.
-Fitz