01-09-2009 07:37 AM
Hello,
I have successfully opened a text file using Excel_WorkbooksOpenText(), but I am having another problem that I am hoping someone can help me with. I am trying to replace all characterers '.' by ','. I don't manage to use Excel_RangeReplace.
My code :
#define EXCEL_ARRAY_OF_CELLS "A1:H3"
...
CA_VariantSetCString (&MyVariant, ".");
CA_VariantSetCString (&MyVariant2, ",");
...
error = CA_VariantSetCString (&MyCellRangeV, EXCEL_ARRAY_OF_CELLS);
error = Excel_WorksheetRange (ExcelWorksheetHandle, NULL, MyCellRangeV, CA_DEFAULT_VAL, &ExcelRangeHandle);
if (error<0) goto Error;
error = Excel_RangeReplace (ExcelRangeHandle,
&ErrorInfo, MyVariant,
MyVariant2, CA_DEFAULT_VAL,
CA_DEFAULT_VAL, CA_DEFAULT_VAL,
CA_DEFAULT_VAL,
CA_DEFAULT_VAL,
CA_DEFAULT_VAL,
CA_DEFAULT_VAL, CA_DEFAULT_VAL,
NULL); */
The function return code : Invalid Paremeter ????
Someone can explain me, please?
I use Excel97.fp, but i have the same problem with Excel2000.
01-09-2009 10:39 AM
Hi,
for the first I would verify wether Excel_RangeReplace needs the range to be activated with Excel_RangeActivate before use.
As a second option, I would substitute all your default values with the appropriate option for the respective parameter (as an example, for the Look At parameter you could specify ExcelConst_xlPart or ExcelConst_xlWhol, as defined in the include file for the instrument). On my machine I am using excel2000 and Excel_RangeReplace requires few parameters than those you are passing but this may depend on instrument version.
But since you are starting from a text file, you may find easiest to preprocess it with standard file I/O functions replacing dots before opening it in Excel.