How to distribute Excel file with its XLL file (Excel DNA) and the C# DLL

594 views
Skip to first unread message

Emmanuel GUIGNIER

unread,
Jul 30, 2015, 5:41:17 PM7/30/15
to Excel-DNA
Good evening everybody,

For me, the night is on (11:30 PM) !
But not for all people around the world (America for example).
So I hope an answer for tomorow morning,it would be helpfull :)  ... if you want and you can !!

I built a C# DLL using ExcelDna. This DLL containts a form which is fully interfaced with the application Excel.
This DLL works fine. I can exchange information between the Form and Excel, managing shapes and other data.
As the ExcelDna's documentation says, I have those files in my directory (see pict1.jpg).

In the Excel file, the ThisWorkBook_Open() function contains this code :
Dim oAddIn As AddIn    
Set oAddIn = Application.AddIns.Add(Filename:=ThisWorkbook.Path & "\ClassLibrary2.xll")
oAddIn
.Installed = True
Application.Run "OuvrirFormulaire"

It works fine in the build directory.

BUT, I want to give those files to another collegue.
To simulate that, I when I MOVE the files to another directory, Excel sends a message as below (Error 1004 : see pict2.jpg).
Excel can't find the XLL file ... because Excel has memorizes the previous location for the XLL file.
To solve that, I need to go in the add-in menu in Excel, choose "ClassLibrary2" option, receive a message from Excel which says that It can't find the XLL file and propose me to delete this entry in the list. I clic OK.
I launch my Excel file another time, and this time, Excel found the correct XLL file location ... and It works fine.

QUESTION : How can I manage this distribution without any problem for me when I want to change the directory, or for another end-user ??

Thanks a lot for your help and experience !!
Best regard.

Emmanuel
pict1.jpg
pict2.jpg

Govert van Drimmelen

unread,
Jul 31, 2015, 3:38:14 AM7/31/15
to Excel-DNA, e.gui...@free.fr
Hi Emmanuel,

You can't move the .xll file and open from another directory when it is already open in Excel.

Maybe you can go through the AddIns collection, and check for the AddIn that represents the alread-open .xll file, and set it to Installed=false.
Then Add the new AddIn from the new path, and set Installed=true on the new instance.

I don't think the Excel workbooks themselves store anything about the .xll location.
So it's just your installed AddIns that know of the location.

-Govert

Emmanuel GUIGNIER

unread,
Aug 2, 2015, 3:42:45 AM8/2/15
to Excel-DNA, e.gui...@free.fr
Hi Govert,

Thank you very much for your answer.
I was surprised to see that you are from Johanesbourg !!

I agree with you. I tried several approaches to uninstall XLL in EXCEL by VBA, but without any success.
It could be done only manualy.

Have a good day.
Best regard.

Emmanuel (Lyon - France)
Reply all
Reply to author
Forward
0 new messages