Repacking old Add In after update

Feb 3, 2016 at 10:31 PM
Hi,

I update Excel DNA and as a result the I am unable to update my packed add in. I.e the code still runs but none of the changes are taking place as the add-in isn't being repacked.
Also, the .dna file that has the following
<DnaLibrary Name="First Add-In" RuntimeVersion="v4.0">
<ExternalLibrary Path="MyLibrary.dll" Pack="true"/>
</DnaLibrary>

has _UNINSTALLED in front of it. What does that mean ? Can someone help me figure out what changes I need to make ?

Thanks

Bilal
Coordinator
Feb 4, 2016 at 11:26 AM
Hi Bilal,

It sounds like you need to install (or re-install) the Excel-DNA NuGet package.

The "_UNINSTALLED" bit is set up when the NuGet package is uninstalled, so that this file (which was created when the package got installed, but now might be modified) does not just get deleted.

If it stays broken, you might want to make a fresh Class Library project, install the ExcelDna.AddIn package, and either bring your existing code in, or compare configurations to see what's wrong.

-Govert
Feb 4, 2016 at 5:54 PM
Hi Govert,

I created a fresh new test add in installing the ExcelDna package. It created a packed add-in but I couldn't call in the test function I put in place. Any reason why that might be the case ?
I followed instructions in the document in case I may have missed something out.

Regards,

Bilal
Coordinator
Feb 4, 2016 at 6:29 PM
Hi Bilal,

What happens when you press F5?
Does it start Excel?

Can you paste your test function - maybe there's something funny with it?

-Govert
Feb 4, 2016 at 7:17 PM
Hi Govert,

Figured it out, I had Class rather than Module

Imports ExcelDna.Integration
Public Module Test
    Public Function MyString(name As String) As String
        Return "Hello" + name
    End Function
End Module
What I have also found is that
Imports ExcelDna.Integration
stays greyed out. Why is that ?
Coordinator
Feb 4, 2016 at 7:46 PM
Edited Feb 4, 2016 at 7:47 PM
OK great!

Inside a Class you need to mark the functions as "shared":
Public Class Test
    Public Shared Function MyString(name As String) As String
        Return "Hello" + name
    End Function
End Module
The "Imports" statement just brings in the namespace, so that you can say "ExcelFunction" instead of "ExcelDna.Integration.ExcelFunction" in your code.
It's greyed out because it is not used in your code.

You might use it like this:
Imports ExcelDna.Integration
Public Module Test
    <ExcelFunction(Description:="My useful function")> _
    Public Function MyString(name As String) As String
        Return "Hello" + name
    End Function
End Module
-Govert
Feb 4, 2016 at 8:03 PM
Hi Govert,

Thanks for the pointers. Much appreciated.

Regarding the following:
    <ExcelFunction(Description:="My useful function")> _
Would I need to put that before every function ? or can I just state it when I declare the module ?

Bilal
Coordinator
Feb 5, 2016 at 4:07 AM
Hi Bilal,

The "ExcelFunction" attribute is not required at all. If you do add it to a function, the description will be shown in the function wizard.
There is also an "ExcelArgument" attribute that you can add to parameters.

-Govert