Write a custom function myfunc (xa: lpXLOPER), the return value of a function for the number of rows in the xa,
Completion of registration, open the excel when using, such as the return value of abnormal situations:
=myfunc (A12), 11, the return value=myfunc (A15), 14, the return value parameter for the current table cell, the return value is correct,
=myfunc (sheet2! A12), 11, the return value=myfunc (sheet2! A15), 14, the return value parameter for the other table cell, the return value is 653, the return value is not a correct value,
Somehow when parameters for reference of the other table cell, the function of the return value is wrong?
The function myfunc (xa: lpXLOPER) : lpXLOPER; Stdcall;
Var
Tempxloper xres, xSheetname: XLOPER;
The begin
Excelappa. Connect;
Tempxloper. Xltype:=xltypenum;
Tempxloper. Val. Num:=xa. Val. Sref. Ref. RwFirst;
Result:=@ tempxloper;
end;
The function Register_Adjust20: integer;
Var
S: Shortstring;
The begin
Res. Xltype:=xltypeerr;
Res. Val. Err:=xlerrvalue;
S:=GetName;
PxModuleText. SetStr (s);
PxProcedure. SetStr (' myfunc ');
PxTypeText. SetStr (' RP! ');
//R Excel 's XLOPER data structure
PxFunctionText. SetStr (' myfunc);
PxArgumentText. SetStr (' strX ');
PxMacrotype. SetNum (1);
PxCategory. SetStr (AddInCategory);
EResult:=Excel4V (xlfregister @ res, 8,
[pxModuletext thelpxloper,
PxProcedure thelpxloper,
PxTypeText thelpxloper,
PxFunctionText thelpxloper,
PxArgumentText thelpxloper,
PxMacroType thelpxloper,
PxCategory thelpxloper,
Zlpxloper]);
Asm pop sink;
end;//Never Remove
Result:=trunc (res) val) num);
end;