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

Lee Z picture Lee Z · Sep 4, 2013 · Viewed 11.3k times · Source

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

Answer

Govert picture Govert · Sep 11, 2013

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.