R
RK
I have written an xll that uses Excel4 to callback the Excel 2003 C API. The
built-in Excel function I am interested in calling back is EOMONTH. Since
Excel 2003 C API does not have an enumeration for this function (Excel 2007
C API does), I resorted to using xlUDF as follows:
int result = 0;
XLOPER argDate, argOffset, funcResult, funcName;
argDate.xltype = xltypeNum;
argDate.val.num = 39607;
argOffset.xltype = xltypeNum;
argOffset.val.num = 0;
funcName.xltype = xltypeStr;
funcName.val.str = "\007EOMONTH";
result = Excel4(xlUDF, &funcResult, 3, &funcName, &argDate, &argOffset);
This works just fine. The Excel xll documentation mentions that one can use
xlfEvaluate to get a reference to a function and use the reference instead
of xlUDF which is supposedly slower. This is apparently true if the callback
function is to be called repeatedly.
My question: how can I make xlfEvaluate work? My attempts at getting a
reference to EOMONTH using xlfEvaluate have failed. I have tried the
following with no success:
XLOPER funcName1;
funcName1.xltype = xltypeStr;
funcName1.val.str = "\010!EOMONTH";
result = Excel4(xlfEvaluate, &funcResult, 1, &funcName1);
Excel4 returns 0 which means it thinks that it is doing something right but
the funcResult.xltype code is 16 which is xltypeErr. I suspect that it has
something to do with the way I have entered "!EOMONTH" or that xlfEvaluate
works only with VBA macros, defined cell names, etc.
Any help is appreciated. Thanks.
built-in Excel function I am interested in calling back is EOMONTH. Since
Excel 2003 C API does not have an enumeration for this function (Excel 2007
C API does), I resorted to using xlUDF as follows:
int result = 0;
XLOPER argDate, argOffset, funcResult, funcName;
argDate.xltype = xltypeNum;
argDate.val.num = 39607;
argOffset.xltype = xltypeNum;
argOffset.val.num = 0;
funcName.xltype = xltypeStr;
funcName.val.str = "\007EOMONTH";
result = Excel4(xlUDF, &funcResult, 3, &funcName, &argDate, &argOffset);
This works just fine. The Excel xll documentation mentions that one can use
xlfEvaluate to get a reference to a function and use the reference instead
of xlUDF which is supposedly slower. This is apparently true if the callback
function is to be called repeatedly.
My question: how can I make xlfEvaluate work? My attempts at getting a
reference to EOMONTH using xlfEvaluate have failed. I have tried the
following with no success:
XLOPER funcName1;
funcName1.xltype = xltypeStr;
funcName1.val.str = "\010!EOMONTH";
result = Excel4(xlfEvaluate, &funcResult, 1, &funcName1);
Excel4 returns 0 which means it thinks that it is doing something right but
the funcResult.xltype code is 16 which is xltypeErr. I suspect that it has
something to do with the way I have entered "!EOMONTH" or that xlfEvaluate
works only with VBA macros, defined cell names, etc.
Any help is appreciated. Thanks.