Using XLOPERs to Communicate with C Functions

You can use XLOPERs when your function is called by C. This is the most flexible way to communicate with Microsoft Excel. To do this, use the R data type in the third argument to the REGISTER function. For example:

=REGISTER("myDLL","myFunc","RR","MyFunc","Value")

This would register a function declared as:

LPXLOPER myFunc(LPXLOPER px);

You can also use data type P in the third argument. The distinction between data types P and R is significant only when the argument being passed is specified as a reference. Type R passes the reference as xltypeRef. The programmer must then coerce the xltypeRef to an xltypeMulti and walk the XLOPER array to obtain the values. Data type P passes the value represented by the reference.