xlCoerce

This function converts one type of XLOPER to another, or looks up cell values on a sheet.

Returns the coerced value.

Syntax

Excel4(xlCoerce, LPXLOPER pxRes, 2, LPXLOPER pxSource,
LPXLOPER pxDestType);

pxSource

The source XLOPER that needs to be converted. May be a reference if you want to look up cell values.

pxDestType (xltypeInt)

A bit mask of which types you are willing to accept. You should use the bitwise OR operator ( | ) to specify multiple possible types. If this argument is omitted, it is assumed that you want to convert a reference to any nonreference type (this is handy for looking up cell values). This argument is optional.

Example

\SAMPLES\EXAMPLE\EXAMPLE.C

short WINAPI xlCoerceExample(short iVal)
{
    XLOPER xStr, xInt, xDestType;

    xInt.xltype = xltypeInt;
    xInt.val.w = iVal;

    xDestType.xltype = xltypeInt;
    xDestType.val.w = xltypeStr;

    Excel4(xlCoerce, &xStr, 2, (LPXLOPER)&xInt,
        (LPXLOPER)&xDestType);

    Excel4(xlcAlert, 0, 1, (LPXLOPER)&xStr);
    Excel4(xlFree, 0, 1, (LPXLOPER)&xStr);

    return 1;
}

Related Function

xlSet