LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

excel_rangereplace

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.
                                  

0 Kudos
Message 1 of 2
(2,853 Views)

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.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 2
(2,843 Views)