xlAutoRegister

Provided by some stand-alone DLLs (XLLs). This entry point is called by Microsoft Excel when a REGISTER or CALL statement tries to register a function without specifying the type_text argument. If that happens, Microsoft Excel calls xlAutoRegister, passing the name of the function that the user tried to register. xlAutoRegister should use the normal xlRegister function to register the function; but, this time, it must specify the type_text argument. This function is required only if the DLL wants to support registering its individual entry points automatically.

If the function name is unknown, this function returns a #VALUE! error (xltypeErr). Otherwise, it returns whatever REGISTER returned (xltypeNum).

Syntax

LPXLOPER WINAPI xlAutoRegister(LPXLOPER pxName);

pxName (xltypeStr)

The name of the function that needs to be registered. Not case-sensitive.

Example

\SAMPLES\FRAMEWRK\GENERIC.C

LPXLOPER WINAPI xlAutoRegister(LPXLOPER pxName)
{
    static XLOPER xDLL, xRegId;
    int i;

    // This block first initializes xRegId to a
    // #VALUE! error.     This is done in case a function
    // is not found to register.     Next, the code loops
    // through the functions in rgFuncs[]     and uses
    // lpstricmp to determine if the current row in
    // rgFuncs[] represents the function that needs
    // to be registered.     When it finds the proper row,
    // the function is registered and the     register ID
    // is returned to Microsoft Excel. If no matching
    // function is found, an xRegId is returned
    // containing a #VALUE! error.

    xRegId.xltype = xltypeErr;
    xRegId.val.err = xlerrValue;

    for (i = 0; i < rgFuncsRows; i++)
    {
        if (!lpstricmp(rgFuncs[i][0], pxName->val.str))     
        {
            Excel(xlGetName, &xDLL, 0);

            Excel(xlfRegister, 0, 8,
                (LPXLOPER)&xDLL,
                (LPXLOPER)TempStr(rgFuncs[i][0]),
                (LPXLOPER)TempStr(rgFuncs[i][1]),
                (LPXLOPER)TempStr(rgFuncs[i][2]),
                (LPXLOPER)TempStr(rgFuncs[i][3]),
                (LPXLOPER)TempStr(rgFuncs[i][4]),
                (LPXLOPER)TempStr(rgFuncs[i][5]),
                (LPXLOPER)TempStr(rgFuncs[i][6]));

            /* Free the XLL filename */
            Excel(xlFree, 0, 1, (LPXLOPER)&xDLL);

            return (LPXLOPER)&xRegId;
        }
    }

    return (LPXLOPER)&xRegId;
}

Related Function

xlAutoOpen