ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   cell reference in C-API xll (https://www.excelbanter.com/excel-programming/339748-cell-reference-c-api-xll.html)

Janwillem van Dijk[_2_]

cell reference in C-API xll
 

I have a function compiled into an xll add-in using a pascal version of
the C-API for getting the formula in a cell as a string. It needs the
row and column index of a cell and works fine.

However, I would rather have a cell as parameter than its indices,
giving a function like:
function GetFormulaInCellXl(var CellXl: TXloper): PxlOper; stdcall;

However I do not succeed in getting this right for xlfGetCell. It always
returns #VALUE. (I can also manage it to crash excel)

Question: How do you get the row,col values of a cell that is parameter
to a function. (tips using C also welcome.)

The essential lines of the working version are below:

function GetFormulaXl(var RowXl, ColXl: TXloper): PxlOper; stdcall;
....
.... get row and col from XlOpers RowXl, ColXl
....
//Set reference
ref.xlType := xltypesref;
ref.val.sref.Count := 1;
with ref.val.sref.xlref do
begin
firstrow := Row;
firstcol := Col;
lastrow := Row;
lastcol := Col;
end;
tempInt.xlType := xlTypeInt;
tempInt.val.int := 6;
xlresult := _Excel4v(xlfGetCell, @ResultXlOper,
2, [@TempInt, @Ref]);
//Returns the formula in the default reference style
//xlfGetFormula would return R1C1 style
//_Excel4v is excel4v with "asm pop sink end;"
//for removing 4 bytes left by Excel4v function call
end;
result := @ResultXlOper;
....


It is registered with 'PPP#' as type

Thanks,
Janwillem

Stephen Bullen[_4_]

cell reference in C-API xll
 
Hi Janwillem,

Questions about Excel's C Api and xlls are generally answered in the
Public.Excel.sdk newsgroup. You might like to repost your question
there.

Regards

Stephen Bullen
Microsoft MVP - Excel




All times are GMT +1. The time now is 12:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com