Login to participate
Endpoint Management & Virtualization ArticlesRSS

Installing and Loading Excel Addins with WiseScript

WiseUser's picture

Here's a pretty cool way to harness the Power of Microsoft's Excel (via WiseScript) to add a little extra 'kick' to your garden variety MSI. If you're having trouble including Excel Addins in your distribution packages, here's the secret sauce.

Definition, Please

Let's start with a definition. What is an Excel Addin?

An Excel Add-In is a file (usually with an .xla or .xll extension) that Excel can load when it starts up.

There are two methods of adding the Excel Addins through MSI Package:

  1. Best way is to drop the .xla or .xll files to XLstart folder in Office folder. Say if its Office XP or 2002 - then the folder will be (C:\Program Files\Microsoft Office\Office10\XLStart)
  2. Placing the Addin in the following user-specific registry key. When the user launches Excel the Addins will be loaded as per the order of OPEN keys.
    HKCU\Software\Microsoft\office\<version>\Excel\Options 
    
    

The first method described here is pretty much straight forward, we can achieve it by placing the files in the Xlstart folder.

The problem with the second method is that when we do a setup capture of the application, Wise captures these Addin keys as OPEN, OPEN1, OPEN2 depending on the number of Excel Addins present. We cannot ship these keys as such using an MSI as it will replace the registry keys in the destination computer.

Solution: In order to overcome this issue, we need to write a WiseScript that will fetch the current OPEN keys and increment the OPEN key Number. If OPEN1, OPEN2 are already present in the box, then the script will install the Addin as OPEN3 and so on. This will avoid corrupting the existing Addins on the box.

This is a sample WiseScript designed to overcome this issue. The script accepts a value for the Addin using a variable called ADDIN.

Click to view.

Harsh's picture

hardcoded Path

Nice tip.
But I think this script is hardcoded for one defined version i.e I can see Office Path and version is hardcoded for File as well as registy.
as given example this will work only for office XP or 2000.
and wisescript will fail for any other version.
Can we fetch public property (set using system serach to identify office version)in wisescript and alter it for removing hardcoding? or it wont possible?

The best alternative what i can think is VBScript.

¬Cheerz
Harsh

ScoopD's picture

wrong method - use the API with vbs

The recommended method of installing an excel add-in is to use the API via a vb script. This method is not Office version dependant as this hook has existed since Office 97 & still exists in Office 2007.
See the following code & change the example path of the add-in to your file. NOTE: this path can be anywhere on the computer, or anywhere else that is accessible during the running of this script and the launch of Excel, such as a network drive if you really want (wouldn't recommend that though).

Dim oXL
Dim oAddin
Set oXL = CreateObject("Excel.Application")
oXL.Workbooks.Add
Set oAddin = oXL.AddIns.Add("C:\xpaddin.xll", True)
oAddin.Installed = True
oXL.Quit
Set oXL = Nothing

Then to remove you do the opposite action, as below. NOTE: you do not have to know the path to the add-in for the removal

Dim oXL
Dim crAddin
on error resume next

Set oXL = CreateObject("Excel.Application")
for i = 1 to oXL.Addins.Count
	Set crAddin = oXL.Addins.item(i)
	If crAddin.Name = "xpaddin.xll" then
		crAddin.Installed = False
	End If
next

oXL.Quit
Set oXL = Nothing