UDF overloads

173 views
Skip to first unread message

markd

unread,
Nov 5, 2009, 11:54:50 AM11/5/09
to ExcelDna
Hopefully a quick question - is it possible to create 2 UDFs with the
same name but with a different number of parameters?

I tried it briefly and it seems as though only the second overload is
displayed in Excel's functions dialog box.

Mark

Govert van Drimmelen

unread,
Nov 6, 2009, 3:38:07 AM11/6/09
to ExcelDna
Hi Mark,

There is no special support for function overloading in Excel or
ExcelDna.

However, you can make a 'union' function that has arguments of type
object, and do the switching to call the right internal implementation
based on which parameters are passed, their types or whether they are
missing. ExcelDna allows you to expose _any_ kind of function that
an .xll add-in can expose to Excel.
As a potential feature, ExcelDna could in theory synthesize the switch
function from the overloaded functions it finds in the assembly. I'm
not sure I would see this as a high priority, though I'm planning some
future changes that could potentially make this kind of feature easier
to add.

Regards,
Govert
Reply all
Reply to author
Forward
0 new messages