XLL+ Class Library

CXlOper::CallAddin

Call an add-in function directly, and store the result

[C++]
LPXLOPER CallAddin(
   LPXLOPER lpxlopResult
);

Parameters

lpxlopResult

The return value of an add-in function.

Remarks

This function can be used to call an add-in function directly from another add-in function. The result of the call will be placed in the calling CXlOper instance.

For example:

extern "C" __declspec( dllexport )
LPXLOPER BsTheta(double Spot, BOOL Put, const COper* Div, double
    Borrow, double ImpVol, double Strike, long ValueDate, long
    Maturity, double RiskFree, short DayCount)
{
    CXlOper xloResult;
//}}XLP_SRC

    // Call the array version of the function
    CXlOper xloCalc;
    xloCalc.CallAddin(BsCalc(Spot, Put, Div, Borrow, ImpVol, Strike, 
                             ValueDate, Maturity, RiskFree, DayCount));

    // Extract a cell from the array
    if (xloCalc.IsArray())
        xloResult = xloCalc.Cell(6, 1);
    else
        xloResult = xloCalc;

    return xloResult.Ret();
}

See the SimpOpt sample for an example of the method in use.

Caution

This is the recommended way to call add-in functions directly. Any other method (such as simply copying the return value) may result in memory leaks.

Requirements

Header: xllplus.h

See Also

CXlOper Class | CXlOper Methods | CXlOper::Ret() | CXlOper::Excel()