Last modified: March 18, 2009
Applies to: Excel 2010 | Office 2010 | VBA | Visual Studio
Excel calls the xlAutoRegister function whenever a call has been made to the XLM function REGISTER, or the C API equivalent xlfRegister function, with the return and argument types of the function being registered missing. It allows the XLL to search its internal lists of exported functions and commands to register the function with the argument and return types specified.
Starting in Excel 2007, Excel calls the xlAutoRegister12 function in preference to the xlAutoRegister function if it is exported by the XLL.
Excel does not require an XLL to implement and export either of these functions.
If xlAutoRegister/xlAutoRegister12 tries to register the function without supplying the argument and return types, a recursive calling loop occurs which eventually overflows the call stack and crashes Excel.
Your implementation of xlAutoRegister should perform a case-insensitive search through your XLL's internal lists of the functions and commands it exports looking for a match with the passed-in name. If the function or command is found, xlAutoRegister should attempt to register it, using the xlfRegister function, making sure to provide the string that tells Excel the return and argument types of the function, as well as any other required information about the function. It should then return to Excel whatever the call to xlfRegister returned. If the function was registered successfully, xlfRegister returns an xltypeNum value containing the Register ID of the function.
See the file SAMPLES\EXAMPLE\EXAMPLE.C for an example implementation of this function.