Hi Norbit,
The problem has been reported before, but I have no good answer for
you. This seems to be a bug in the Excel 2007 API.
You might know that the maximum length of strings supported by the API
was 255 characters in versions before Excel 2007. This limitation was
removed in Excel 2007, but some remnants remain - I think this is one
such case. When registering your function, ExcelDna calls the
xlfRegister function (
http://msdn.microsoft.com/en-us/library/
bb687900.aspx). The argument names (which are the argument name in
your method unless overridden by setting the Name property of the
ExcelArgument attribute) are concatenated to a single string with ','
separators, and passed to the optional 5th argument (pxArgumentText)
of xlfRegister. It seems when this string (the total of joined
argument names with ','s) is longer that 255 chars, the register call
to Excel fails.
As a work-around, you can make your argument names shorter - this will
allow you to register functions with more arguments.
I also need some advice on how to deal with this in ExcelDna. Please
let me know which of the following options you would prefer for the
next version of ExcelDna:
1. Leave it as is - try to register with the full list of arguments.
2. Truncate the argument name string to 255 chars - this means that
all arguments will not be displayed in the function wizard.
3. If the argument name string is longer than 255 chars, leave it out
of the registration call. Then Excel constructs names for the
arguments (like 'String' and 'Argument'), but at least the full list
is in the function wizard.
4. Any other ideas - is this a bug in ExcelDna that does not appear in
the other .xll add-in tools?
Regards,
Govert