09-15-2015 07:41 AM
I'm using LabWIndows/CVI 2010 and I'm trying to save an open Excel XLS file as a CSV but I cannot figure out how to specify the fileformat parameter. excel2000.h contains #defines for all the file formats but I cannot pass the define to Excel_WorksheetSaveAs. WHat do I need to cast the define to for it to work?
Thanks in advance.
Solved! Go to Solution.
09-16-2015 05:01 PM
Hi, I believe this has been addressed here:
09-16-2015 05:03 PM
Thanks for the reply. My problem isn't opening the XLS file, it's saving it as a CSV. None of the sample code uses the SaveAs function.
09-17-2015 06:02 AM
You could probably get what you want by calling Excel_WorkbookSaveAs with ExcelConst_xlCSV constant in "File Format" parameter.
09-21-2015 03:36 PM
I've tried casting ExcelConst_xlCSV to CA_VariantInt (you cant pass it directly, it wont compile) as the File Format and that gives me an 0x80004002 Interface Not Supported. Tried various other ExcelConst values as well and always get the same error.
09-22-2015 02:50 AM - edited 09-22-2015 02:55 AM
Now, this is strange. I hadn't tested originally this option but I made it right now and it is working for me: this instruction effectively create a CSV file out of an Excel workbook I created programmatically exporting test data in an application of mine
errChk (Excel_WorkbookSaveAs (ExcelWorkbookHandle, NULL, MyVariant, CA_VariantInt (ExcelConst_xlCSV), CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, ExcelConst_xlNoChange, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL, CA_DEFAULT_VAL));
(it happened to create a CSV file even if the filename had .xls extension!)
FYI, my environment is Win7Pro SP1 64bit, CVI 2012 FDS SP1, Office 2000 installed.
09-22-2015 07:33 AM
I was using ExcelWorkSheetSaveAs not ExcelWorkBookSaveAs but switching to ExcelWorkBookSaveAs got rid of the error. Thanks for the help!