LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Active cell position

I want to export the position (row and column) of the active cell in Excel to my C-main. I want to define two variables which describe the position of the active cell.
 
I have a program that writes the data to the excel sheet, but only in a static way. For example only in A1, when both variables are set to 1.B2 if both are set to 2 and so on...
 
But i want the program to write the data to the activated cell in the active sheet.
 
 
Can anybody help me?
0 Kudos
Message 1 of 4
(3,001 Views)
Hello jefe,

take a look at the LabWindows/CVI shipping example for excel, you can find examples on using Excel with CVI in the ...cvi\Samples\ActiveX\Excel folder on your machine.

Look at the Excel2000dem.prj, it does something similar to what you describe below (line 662-667 in excel2000dem.c).

Best regards

Benjamin
0 Kudos
Message 2 of 4
(2,970 Views)

Were you able to accomplish this way back then. I am having the same issue. The demo projects do not help in locating and importing a current cell position within an open xlsx file. Are there any more details available?

 

BR

0 Kudos
Message 3 of 4
(1,954 Views)

Accessing a random cell in an Excel sheet is quite easy: this is a function I am using to write a string to a cell with row / col received as function parameters. You can use it a framework to develop your own reading functions.

 

int WriteString (char *text, int col, int row, VARIANT MyVariant, CAObjHandle *ExcelRangeHandle)

{
	int		error = 0;

	errChk (CA_VariantSetCString (&MyVariant, text));
	errChk (Excel_RangeSetItem (*ExcelRangeHandle, NULL, CA_VariantInt (row), CA_VariantInt (col), MyVariant));
	errChk (CA_VariantClear (&MyVariant));

Error:
	return error;
}

 



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?
0 Kudos
Message 4 of 4
(1,944 Views)