Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy an Excel XLL Add-In and automatically register the Add-In in Excel

Tags:

deployment

xll

I have developed an Excel XLL using ExcelDNA and C#. I am at the point where I would like to begin testing the deployment, but cannot find much information that actually provides steps that work.

My project was developed as a Class library with ExcelDna references. In the .dna file, I have the code below that will pack all resources into a packed version of the XLL (i.e. the Pack="true" attribute).

<DnaLibrary Name="ExcelXLL" RuntimeVersion="v4.0" Language="C#">
  <ExternalLibrary Path="ExcelXLL.dll" LoadFromBytes="false" Pack="true" />

I would like to deploy the packed XLL to the target machine in the path:

%APPDATA%\Microsoft\AddIns

In order to automatically register the XLL with Excel, I need to add a registry key that depends on the version of Excel that the user has.

For instance, on my computer (Windows 7 64 bit running Excel 2007 32-bit), I would need to add a registry key to the following path:

HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Excel\Options\

The key would be type REG_SZ with the name OPEN (or OPEN1, OPEN2, etc.) and the value /R "ExcelXLL-packed.xll"

I have 2 problems though. The first is in determining which version of Excel that the user has to get the correct path and the 2nd is to determine the correct OPEN version that I need to create (for example, if the user already has OPEN, OPEN1, and OPEN2 then I would create an OPEN3 key).

I am trying to do the installation using either the Setup and Deployment project or a InstallShield LE project and cannot determine how to go about this. Does anyone know how to do this or a better way of doing it?

EDIT 1:

I have done a great deal of research on this and have looked at several windows installers.

In the Package and Deployment and InstallShield LE, I can get the install/uninstall to work by putting an installer class into my class library and bundling project output with the install. In this approach, I handle inserting/removing the registry key using the installer class. The problem that I have is that the user must uninstall first before running a new install (no update capability).

I downloaded the Setup Factory demo version and can get install/update to work but cannot do the framework check (not shipped with the demo). Also, the uninstall fails (though I may be able to get this to work with some more investigation).

I am interested in using the WiX installer, but would like to know if anyone has a sample of how to perform the deployment using WiX. I would also like to know if I need to use the installer class or if there is a different way to handle the search for the OPEN[n] key under HKCU\Software\Microsoft\Office[Version].0\Excel\Options. If I were to use the project output to enable the installer class, then I need to have 2 separate target directories (one under Program Files for the basic project output and one under %appdata%\Microsoft\AddIns for the packed XLL).

Any help is greatly appreciated.

Thanks,

Lee

like image 988
Lee Z Avatar asked Sep 03 '13 22:09

Lee Z


People also ask

How do I use XLL files in Excel?

XLL files can be opened with Microsoft Excel. If double-clicking an XLL file doesn't open it in Excel, you can do it manually via the File > Options menu. Select the Add-ins category and then choose Excel Add-ins in the Manage drop-down box. Choose the Go button and then Browse to locate it.

How do you make add-in load at startup Excel?

To register an addIn so that it loads automatically when Excel starts, open the Registry Editor and go to HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\Addins\. Create a new key under Addins for your addIn (without the . xlam extension). Set the Default value for this key to 1.

Could not load the Excel Add-Ins automatically?

Disabled Application Add-ins To solve the problem, select “Disabled Items” in the “Manage:” drop down at the bottom of the dialog and click “OK”. In the Disabled Items dialog select the add-in and click “Enable” and then close the dialog.


2 Answers

To detect Excel 32-bit vs. 64-bit, you can check the registry: Detect whether Office is 32bit or 64bit via the registry

For the OPEN, OPEN1, OPEN2 etc. you typically need a Custom Action in the install script that enumerates the keys.

like image 56
Govert Avatar answered Oct 07 '22 09:10

Govert


Using IsWix and Wix 3.7, I was able to resolve this.

Useful links for how to register the components are as follows:

For generating a C# class to handle Windows Installer Custom Actions: http://www.codeproject.com/Articles/132918/Creating-Custom-Action-for-WIX-Written-in-Managed?fid=1599130&df=90&mpp=25&noise=3&prof=False&sort=Position&view=Quick&spc=Relaxed&select=4131367&fr=1#xx0xx

http://blogs.msdn.com/b/jschaffe/archive/2012/10/23/creating-wix-custom-actions-in-c-and-passing-parameters.aspx

For setting the property of the CustomAction.config file to Content WIX Custom Actions built for .Net Framework 4.0 does not work? Ways to resolve?

EDIT 1:

For general knowledge on WiX (Very important) http://channel9.msdn.com/blogs/scobleizer/wix-team-the-most-used-piece-of-software-at-microsoft-and-its-open-source#Page=2

like image 30
Lee Z Avatar answered Oct 07 '22 10:10

Lee Z