ExcelDna 1.9.0-rc3: Issues with ParamArray in VB.NET UDFs

77 views
Skip to first unread message

SJ Rhi

unread,
Jul 17, 2025, 4:19:05 AMJul 17
to Excel-DNA
Hi  Govert,

I'm experiencing some unexpected behavior with ParamArray when developing Excel UDFs using ExcelDna 1.9.0-rc3. I installed the NuGet packages and am trying to use a ParamArray as shown in the sample code below, but it doesn't seem to be working as expected.

1. When I enter a third argument (e.g., =DnaAddValues(1, 2, 3, 4) ), Excel treats it as a #VALUE! error, and this argument is not passed to the UDF.
2. The function only seems to work correctly when the second argument is explicitly an array (e.g., =DnaAddValues(1, {2, 3, 4}) )
3. IntelliSense doesn't display help for the third argument onwards, even though it should be part of the ParamArray.

image.png

My VB.NET project configuration is as follows:
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ExcelDna.Integration" Version="1.9.0-rc3" />
<PackageReference Include="ExcelDna.Interop" Version="15.0.1" />
<PackageReference Include="ExcelDna.Addin" Version="1.9.0-rc3" />
<PackageReference Include="ExcelDna.IntelliSense" Version="1.9.0-rc3" />
<PackageReference Include="ExcelDna.Registration" Version="1.9.0-rc3" />
<PackageReference Include="ExcelDna.Registration.VisualBasic" Version="1.9.0-rc3" />
<PackageReference Include="ExcelDna.XmlSchemas" Version="1.0.0" />
</ItemGroup>

And here is my sample UDF code:
    <ExcelFunction>
    Function DnaAddValues(<ExcelArgument(Name:="Value1", Description:="value")> val1 As Double,
                          <ExcelArgument(Name:="Values", Description:="values")> ParamArray vals As Double()) As Double
        Dim sum As Double = val1
        If vals IsNot Nothing Then
            For Each val As Double In vals
                sum += val
            Next
        End If
        Return sum
    End Function


Govert van Drimmelen

unread,
Jul 17, 2025, 4:43:07 AMJul 17
to exce...@googlegroups.com

The code you show should work, and does work right on my machine.

 

Is this the whole project, or perhaps embedded in an existing add-in where you are doing explicit registration processing in your AutoOpen()?

The new extended registration support works as long as you don’t have ‘ExplicitRegistration’ enabled in the project or .dna file (if you have a .dna file – you shouldn’t need one anymore – it’s auto-generated by the build).

 

You should be able to remove the two “ExcelDna.Registration****” packages, as well as “ExcelDna.Integration”.

Then for the IntelliSense to work you need something like this:

 

Imports ExcelDna.Integration

Imports ExcelDna.IntelliSense

 

Public Class MyAddIn

    Implements IExcelAddIn

 

    Public Sub AutoOpen() Implements IExcelAddIn.AutoOpen

        IntelliSenseServer.Install()

    End Sub

 

    Public Sub AutoClose() Implements IExcelAddIn.AutoClose

        IntelliSenseServer.Uninstall()

    End Sub

 

End Class

 

I then get:

 

-Govert

 

 

 

 

From: exce...@googlegroups.com <exce...@googlegroups.com> On Behalf Of SJ Rhi
Sent: 17 July 2025 10:19
To: Excel-DNA <exce...@googlegroups.com>
Subject: [ExcelDna] ExcelDna 1.9.0-rc3: Issues with ParamArray in VB.NET UDFs

 

Hi  Govert,

 

I'm experiencing some unexpected behavior with ParamArray when developing Excel UDFs using ExcelDna 1.9.0-rc3. I installed the NuGet packages and am trying to use a ParamArray as shown in the sample code below, but it doesn't seem to be working as expected.

 

1. When I enter a third argument (e.g., =DnaAddValues(1, 2, 3, 4) ), Excel treats it as a #VALUE! error, and this argument is not passed to the UDF.

2. The function only seems to work correctly when the second argument is explicitly an array (e.g., =DnaAddValues(1, {2, 3, 4}) )

3. IntelliSense doesn't display help for the third argument onwards, even though it should be part of the ParamArray.

 

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/exceldna/56ad1eae-94ec-4e19-82ba-ce91331f2996n%40googlegroups.com.

image001.png

SJ Rhi

unread,
Jul 17, 2025, 9:35:50 AMJul 17
to Excel-DNA

Thank you for the reply.

As you suggested, I removed the two Registration packages and the Integration package, 

disabled the <ExplicitRegistration> option, 

and finally removed the RegisterFunctions process. 

I've confirmed that it's now working correctly.


I need to use multilingual descriptions for UDFs, 

so I have to apply descriptions with RegisterFunctions depending on the language environment. 

Is there a way to do this?


2025년 7월 17일 목요일 오후 5시 43분 7초 UTC+9에 Govert van Drimmelen님이 작성:

Govert van Drimmelen

unread,
Jul 18, 2025, 5:14:07 AMJul 18
to Excel-DNA
I have a partial answer for you, and we'll try to make it better before the release version.

You can add a public method like this to your add-in:

    <ExcelFunctionProcessor>
    Public Shared Iterator Function ApplyLocalisation(registration As IEnumerable(Of IExcelFunctionInfo), config As IExcelFunctionRegistrationConfiguration) As IEnumerable(Of IExcelFunctionInfo)

        ' This function can be used to apply localization to the functions.
        ' For example, you could modify the names or descriptions based on the user's locale.
        For Each func As IExcelFunctionInfo In registration
            Debug.Print($"Processing function: {func.FunctionAttribute.Name}")
            func.FunctionAttribute.Description = "Localised" & func.FunctionAttribute.Description

            For Each param As ExcelParameterRegistration In func.Parameters
                param.ArgumentAttribute.Description = "Localised " & param.ArgumentAttribute.Description
            Next
            Yield func
        Next

    End Function

That `<ExcelFunctionProcessor>` will be picked up by Excel-DNA and can be used to update the registrations.
If will work for your `ParamArray` function, but at the moment won't work for your standard functions that don't get extra transformations applied.
So, a simple function like this one won't get processed through the function processor:

<ExcelFunction(Description: "Not Localised :-( ")>
Public Shared Function AddThem(d1 As Double, d2 As Double) As Double
    Return d1 + d2
End Function

We're looking at it some more to get a better answer.

-Govert

SJ Rhi

unread,
Jul 18, 2025, 12:25:57 PMJul 18
to Excel-DNA
I've successfully applied the method you provided, 
and now the ParamArray arguments are expanding correctly. 

Additionally, I'm able to change function names 
and provide descriptions for functions and arguments in the user's language. 

Thank you so much!  

2025년 7월 18일 금요일 오후 6시 14분 7초 UTC+9에 Govert van Drimmelen님이 작성:

SJ Rhi

unread,
Jul 20, 2025, 9:50:24 AMJul 20
to Excel-DNA
Hi, Govert,

initially, it seemed a simple function wouldn't be processed by the function processor. 
However, I confirmed that by making all arguments optional, it does get processed, 
and I've applied this to my UDF.  


2025년 7월 18일 금요일 오후 6시 14분 7초 UTC+9에 Govert van Drimmelen님이 작성:
Reply all
Reply to author
Forward
0 new messages