XLL+ Class Library

CXlOper::Coerce() Example

// Function:    CoerceEx
// Purpose:     Uses CXlOper::Coerce to return the contents of a cell

//{{XLP_SRC(CoerceEx)
    // NOTE - the FunctionWizard will add and remove mapping code here.
    //    DO NOT EDIT what you see in these blocks of generated code!
IMPLEMENT_XLLFN2(CoerceEx, "RCA", "CoerceEx", 
    "Address,A1", "Example", "Uses CXlOper::Coerce to return the"
    " contents of an address", "Address of a cell\0TRUE if addres"
    "s is in A1 format, FALSE if it is in R1C1 format", "\0\0",
    1)

extern "C" __declspec( dllexport )
LPXLOPER CoerceEx(const char* Address, BOOL A1)
{
    CXlOper xloResult;
//}}XLP_SRC

    // Attempt to convert the address to a reference
    CXlOper xloRef;
    if (!xloRef.MakeRef(Address, A1))
        return CXlOper::RetError(xlerrValue);

    // Coerce the reference to a value
    xloResult.Coerce(xloRef);

    return xloResult.Ret();
}

Uses

CXlOper::Coerce | CXlOper::MakeRef