Best way to distribute an ExcelDNA .xll file with a VBE Add-In

711 views
Skip to first unread message

Bob Kardell

unread,
Aug 26, 2012, 10:20:09 PM8/26/12
to exce...@googlegroups.com
First, I have an Add-in that I developed through the VBE in Excel.  Recently I found out about ExcelDNA and have updated the Add-In to reference a couple of functions from VB.NET and placed them in a .xll file and packed the file.  The file works fine when I double-click on the file and load it into Excel before running the VBE developed Add-In.  But, if I want to distribute the Add-In along with the .xll what is the best way to write a script to register the .xll for the end user?

I have tried using the v2 and the v4 versions of RegAsm on the packed .xll and on the default (renamed) .xll and each time I receive an error that the ".xll is not a valid .NET assembly".  I have tried it on several different systems - XP, Vista, and Win 7 64 and I get the same error...

If I develop a script using regsrv32 would that work to register the .xll for the end user?

I am trying to figure the easiest way so that the end user does not have to do any further installation...

Second, when trying to run the .xll I can sometimes receive a message that the file is unsigned.  I have a signature on the VBE developed Add-In and have converted it to an EXE so that the macros do not need a signature, but is there a way to sign an .xll file? or to convert the .xll so that there are not macro warnings for the end user?  The reason I ask is that several users have reported that they do not have admin right to install a new signature or change the default macro security settings and I am trying to identify a method for registering / installing / using the .xll without needing admin rights.

Finally, if neither of the above is possible, it it possible to call a .NET function directly from a VBA?

Thank you in advance for any help,

Bob

Patrick O'Beirne

unread,
Aug 27, 2012, 3:48:32 AM8/27/12
to exce...@googlegroups.com
On 27/08/2012 03:20, Bob Kardell wrote:
> Finally, if neither of the above is possible, it it possible to call a
> .NET function directly from a VBA?

Application.run "functioname", arg1, arg2, ...

As long as the functionname is not duplicated by an existing VBA fn in
a workbook or addin, in which case they get priority



Naju Mancheril

unread,
Aug 27, 2012, 8:48:58 AM8/27/12
to exce...@googlegroups.com
If you want to load the .xll from VBA, I think you'd grab the Excel.Application object and invoke RegisterXLL.

Here is the code from C#. I haven't tried this from VBA.

        var app=(Application)ExcelDnaUtil.Application;
        return app.RegisterXLL(path);

path is the path of your .xll file.


You shouldn't need to mess with regasm or regsrv32.


Bob Kardell

unread,
Aug 27, 2012, 8:53:53 PM8/27/12
to exce...@googlegroups.com

Thank you to all!

I set-up two Subs in the main Module - Auto_Open and Auto_Close

and added something like this I found on the net ...

Const xllName = "RegTest.xll"
Const filePath = "C:\Files\RegTest\Debug\" & xllName

Sub Auto_Open
    On Error GoTo ErrorHandler
    Application.RegisterXLL filePath
    Exit Sub
ErrorHandler:
    Debug.Print Err.Number, Err.Description
End Sub

Public Sub Auto_close()
    On Error GoTo ErrorHandler
    Application.ExecuteExcel4Macro "UNREGISTER(""" & xllName & """)"
    Exit Sub
ErrorHandler:
    Debug.Print Err.Number, Err.Description
End Sub

It now loads my dna-packed.xll when the Add-In is opened....
Reply all
Reply to author
Forward
0 new messages