limitations to number of arguments

147 views
Skip to first unread message

Norbit

unread,
Dec 2, 2009, 11:10:52 PM12/2/09
to ExcelDna
Hi.
I am having a problem with using a function in excel 2007 using the
Excel Dna that has 37 arguments. When I reduce the number to 33 it
will load successfully into excel but more than that and it fails.
Is this a known limitation of excel DNA?
My function call is as follows.

public static double GetbalanceValue(string sVersion, object company,
object datasource, string sOutputOptions, object defaultDrillDown,
object snapshots0, object snapshots1, object snapshots2, object
snapshots3, object snapshots4, [ExcelArgument(AllowReference = false),
Optional]object oRangesSelected, [ExcelArgument(AllowReference =
false), Optional] object Par0, [ExcelArgument(AllowReference = false),
Optional]object Par1, [ExcelArgument(AllowReference = false), Optional]
object Par2, [ExcelArgument(AllowReference = false), Optional]object
Par3, [ExcelArgument(AllowReference = false), Optional]object Par4,
[ExcelArgument(AllowReference = false), Optional]object Par5,
[ExcelArgument(AllowReference = false), Optional]object Par6,
[ExcelArgument(AllowReference = false), Optional]object Par7,
[ExcelArgument(AllowReference = false), Optional]object Par8,
[ExcelArgument(AllowReference = false), Optional]object Par9,
[ExcelArgument(AllowReference = false), Optional]object Par10,
[ExcelArgument(AllowReference = false), Optional]object Par11,
[ExcelArgument(AllowReference = false), Optional]object Par12,
[ExcelArgument(AllowReference = false), Optional]object Par13,
[ExcelArgument(AllowReference = false), Optional]object Par14,
[ExcelArgument(AllowReference = false), Optional]object Par15,
[ExcelArgument(AllowReference = false), Optional]object Par16,
[ExcelArgument(AllowReference = false), Optional]object Par17,
[ExcelArgument(AllowReference = false), Optional]object Par18,
[ExcelArgument(AllowReference = false), Optional]object Par19,
[ExcelArgument(AllowReference = false), Optional]object Par20,
[ExcelArgument(AllowReference = false), Optional]object Par21)//,
[ExcelArgument(AllowReference = false), Optional]object Par22,
[ExcelArgument(AllowReference = false), Optional]object Par23,
[ExcelArgument(AllowReference = false), Optional]object Par24,
[ExcelArgument(AllowReference = false), Optional]object Par25)


thanks for any help.

Govert van Drimmelen

unread,
Dec 3, 2009, 10:32:51 AM12/3/09
to ExcelDna
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

Norbit

unread,
Dec 3, 2009, 8:50:35 PM12/3/09
to ExcelDna
Hi Govert.
Thankyou that is very helpful.

I am not sure which option is the best as i am no expert myself. If
the problem lies in the excel API then it's excels fault. Mabye there
is no point adjusting your program because of a bug in excel? I am not
sure...
> > thanks for any help.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages