xll_student
2010-02-09 20:56:16 UTC
I am new to XLL development. I am studying Steve Dalton's book,
Financial Applications Using Excel Add-in Development in C/C++ (2nd edition).
I am trying to use Steve's function from page 298 in my code. The XLL gets
created but when I call the function from Excel 2007 it gives me #VALUE!
error.
Could somebody take a look and let me know what's wrong. The code is pasted
below. The argument string I used is "RJJ". I call it the function Excel
using the following syntax: =Z_GetNote(2,2).
Thank you.
//=============
__declspec(dllexport) XLOPER * _stdcall Z_GetNote(long p_row, long p_col)
{
static XLOPER ret_xloper;
XLOPER arg;
//create a single-cell reference to cell on the current sheet
arg.xltype = xltypeSRef;
arg.val.sref.count = 1;
//values:
arg.val.sref.ref.rwFirst = arg.val.sref.ref.rwLast = (RW) p_row;
arg.val.sref.ref.colFirst = arg.val.sref.ref.colLast = (COL) p_col;
Excel4(xlfGetNote, &ret_xloper, 1, &arg);
//Free up memory allocated for the return value:
ret_xloper.xltype |= xlbitXLFree;
return &ret_xloper;
}
//=============
Financial Applications Using Excel Add-in Development in C/C++ (2nd edition).
I am trying to use Steve's function from page 298 in my code. The XLL gets
created but when I call the function from Excel 2007 it gives me #VALUE!
error.
Could somebody take a look and let me know what's wrong. The code is pasted
below. The argument string I used is "RJJ". I call it the function Excel
using the following syntax: =Z_GetNote(2,2).
Thank you.
//=============
__declspec(dllexport) XLOPER * _stdcall Z_GetNote(long p_row, long p_col)
{
static XLOPER ret_xloper;
XLOPER arg;
//create a single-cell reference to cell on the current sheet
arg.xltype = xltypeSRef;
arg.val.sref.count = 1;
//values:
arg.val.sref.ref.rwFirst = arg.val.sref.ref.rwLast = (RW) p_row;
arg.val.sref.ref.colFirst = arg.val.sref.ref.colLast = (COL) p_col;
Excel4(xlfGetNote, &ret_xloper, 1, &arg);
//Free up memory allocated for the return value:
ret_xloper.xltype |= xlbitXLFree;
return &ret_xloper;
}
//=============