UDF returns a huge number

Jun 20, 2013 at 7:50 PM
Hi,

Run the DNA sample code :
    [ExcelFunction(Description = "Returns the result of xlfGetDocument.", IsMacroType = true)]
    public static object GetDocument(int type_num, string name_text)
    {
        return XlCall.Excel(XlCall.xlfGetDocument, type_num, name_text);
    }
When I type in "=GetDocument" (without brackets and parameters) and hit enter, a huge number returns. Same problem on my own UDFs code.

I found same number for a function name, but different number for different function name. It looks like a register ID or something. This problem does not happen on Excel VBA code ("#NAME?" will be returned for VBA case).

I prefer returning "#NAME?" rather than this huge number. Anyone has idea what is wrong with it?

Thanks, Sherry
Coordinator
Jun 21, 2013 at 11:22 AM
Hi Sherry,

This is indeed the register id for the function. Excel works that way for all functions in .xll add-ins like Excel-DNA.
I don't know of a workaround.

Regards,
Govert
Jun 21, 2013 at 2:13 PM
Thanks Govert