Installing a native Excel addin (
.XLA file) is a two-step
process in Excel:
Copy the addin file to an appropriate location. Most commonly, this would be the folder
%appdata%is a system shortcut for the user’s profile (roaming) folder.
Activate the addin for use in Excel by either using Excel’s addin manager (
Manage add-ins) or by modifying the appropriate registry keys.
While this is easy to do for power users and Excel developers, it is a big challenge for most ‘standard’ users.
Daniel’s XL Toolbox uses a customized script to generate setup files with InnoSetup, the free and flexible setup generator. These setup files automate the process of installing the appropriate version of the addin (for Excel 2000-2003 or for Excel 2007-2013) as well as activating it for use in Excel.
I have now cleaned up this installer script and made it available on GitHub: https://github.com/bovender/ExcelAddinInstaller.
The script can be easily configured for other projects. The documentation is contained in the home page of the GitHub repository.
Under the hood
Determining the target folder for installations
Although native Excel addins (i.e.,
.XLA files) can be loaded
from any folder, Excel’s built-in add-in manager expects these files in a
specific folder in a user’s profile folder:
%appdata% is a shortcut to the current user’s profile folder that works
in all versions of Windows.)
The name of the folder (“Addins” in this example) varies with the language
version of Excel. It is “Addins” for English and German versions of Excel
(and probably for some others as well), but may have be different in other
languages. For example, this folder is called
Invoegtoepassing when a
Dutch version of Excel is installed.
The name of the folder can be retrieved from the registry:
Where “14.0” is the version number of the Office installation.
The ExcelAddinInstaller looks uses this registry key to determine the installation target. If the registry key is not found, it falls back to the default “Addins” and subsequently uses complete paths rather than file names only to register and activate the addin. In this case, users cannot easily see the addin information in Excel’s add-in manager.
Activating the addin
To activate an add-in for use in Excel, a special registry key has to be generated:
Where [i] is either empty (i.e., just “OPEN”) or a consecutive number (e.g., “OPEN1”, “OPEN2”, and so on).
The value of this key is the file name of the addin. If the addin is not stored in the standard location (see above), the complete path has to be stored.
The ExcelAddinInstaller contains a Pascal script that identifies the correct key name to use, and automatically generates a key for the installed addin.
Removing the addin
When an addin that was installed using the ExcelAddinInstaller is uninstalled from the control panel (“Add/Remove Software”), the registry key that was generated during installation has to be removed again, and the consecutive numbering of the “OPEN[i]” keys must be restored.
The ExcelAddinInstaller maintains its own repository of installed addins in the registry using a key derived from the “COMPANY” information that is given in the configuration files:
For each addin that is installed, a subkey is generated using the global unique ID (GUID) that is defined in the InnoSetup configuration file.
During the uninstallation process, the Pascal script looks for information in this repository, and removes the corresponding entries from the Excel registry key. If the repository is empty afterwards, it deletes the entire registry key in order to leave no trace of the installation.