XLOPER xRet, xArg, xRef;
xRef.xltype = xltypeSRef;
xRef.val.sref.count = 1;
xRef.val.sref.ref.rwFirst = 1;
xRef.val.sref.ref.rwLast = 1;
xRef.val.sref.ref.colFirst = 1;
xRef.val.sref.ref.colLast = 1;
xArg.xltype = xltypeInt;
xArg.val.w = 5; //value
Excel4(xlfGetCell, &xRet, 2, &xArg, &xRef);
return xRet.val.str;
In my worksheet, Row 1 Column A contains some value "a" but when I
call my UDF, "=Test()", which contain the above logic, it crashes
Excel. Please advise.
(If you're posting a registered function, it's useful to post the type
string you used to register it, and the prototype.)
Have you examined xRet? I suspect it will be an error, as it looks
like you're calling this from a worksheet. xlfGetCell is accessible
from commands, and macro sheet functions. Have a read of
http://msdn.microsoft.com/en-us/library/bb687835.aspx - specifically
the bit about Different types of functions, and what they can call.
Don't just access fields of a union without checking the discriminator
first. (xltype).
I went into this in a previous reply :
http://groups.google.co.uk/group/microsoft.public.excel.sdk/browse_thread/thread/6f92790ecb82d295
Rgds,
Lee.