Export (0) Print
Expand All
0 out of 3 rated this helpful - Rate this topic

xlUDF

Published: July 16, 2012

Calls a user-defined function (UDF). This function allows a DLL to call Visual Basic for Applications (VBA) user-defined functions, XLM macro language functions, and registered functions contained in other add-ins.


Excel12(xlUDF, LPXLOPER12 pxRes, int iCount, LPXLOPER12 pxFnRef,
LPXLOPER12 pxArg1, ...);

pxFnRef (xltypeRef, xltypeSRef, xltypeStr or xltypeNum)

The reference of the function you want to call. This can be a macro sheet cell reference, the registered name of the function as a string, or the register ID of the function. For XLL add-in functions registered using xlfRegister or REGISTER with the argument pxFunctionText supplied, the ID can be obtained by using xlfEvaluate to look up the name.

pxArg1, ...

Zero or more arguments to the user-defined function. When you are calling this function in versions earlier than Excel 2007, the maximum number of additional arguments that can be passed is 29, which is 30 including pxFnRef. Starting in Excel 2007, this limit is raised to 254, which is 255 including pxFnRef.

Returns whatever value the user-defined function returned.

The following example runs TestMacro on sheet Macro1 in BOOK1.XLS. Make sure that the macro is on a sheet named Macro1.

\SAMPLES\EXAMPLE\EXAMPLE.C

short WINAPI xlUDFExample(void)
{       
   XLOPER12 xMacroName, xMacroRef, xRes;

   xMacroName.xltype = xltypeStr;
   xMacroName.val.str = L"\044[BOOK1.XLSX]Macro1!TestMacro";
   Excel12(xlfEvaluate, &xMacroRef, 1, (LPXLOPER12)&xMacroName);
   Excel12(xlUDF, &xRes, 1, (LPXLOPER12)&xMacroRef);
   return 1;
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.