Andrei Smolin

Updating Office COM add-ins automatically

To test the example described below, click this link, download and run the application installing the sample COM add-in. When the add-in is installed, you start Excel 2000 – 2016 and find the add-in in the UI. Leave Excel open and in a couple of minutes, you’ll get a notification suggesting installing an update. Click Update and get the new add-in version installed. Below I describe creating and deploying such an add-in.

Add-in Express for Office and .NET version 8.7 extended the ClickTwice custom deployment technology with the Automatic Update feature. I’m going to describe several examples demonstrating the feature.

I’ll start with exploring Automatic Update’s default behavior. To demonstrate it, I create a basic COM add-in supporting Excel. The add-in creates a Ribbon label showing the add-in’s version. No other code.

Designing the add-in Ribbon UI

private void AddinModule_OnRibbonBeforeCreate(object sender, string ribbonId) {
        this.adxRibbonLabel1.Caption =
            "Current version: " +
            System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
    }

The add-in Ribbon UI at the run time

The add-in is signed with an Add-in Express certificate.

Signing the add-in

Now I create a setup project. I use the Add-in Express setup project wizard to create a Visual Studio Installer project; WiX and InstallShield are supported as well.

The setup project wizard

The next step is to build the setup project and publish the installer. I follow the steps described in the Add-in Express manual: create a setup project and build it, open the Publish dialog, specify the installer to publish and set preferences. Find more details below.

The default Automatic Update settings are as follows:

The default Automatic Update settings

The default settings of the updater application are:

The default settings of the Updater application

Here are the remaining parameters required for publishing: the installer to publish, the location where to put prepared files, the URL where to look for updates. I’ve specified an icon to be used by the updater application, and signed the installer:

The Publish dialog

If you click Publish, Add-in Express shows a warning: You’ve chosen to sign adxloader.dll.manifest. You should also select the "Sign ‘version_info.xml’ file" check box; see Preferences.

Set Sign ‘version_info.xml’ file as recommended, and click Publish again to get all the files prepared. The final step of publishing the initial add-in version is this: upload the version_info.xml file and folders from the MSIPublish folder (see your add-in project folder) to the location which is accessible for an end user via the URL specified in the Publish dialog (see the Installation URL field in the screenshot above):

The folder structure created when publishing the add-in

Provide an end user with a link pointing to the downloader. In this example, this link is http://cdn.add-in-express.com/samples/automatic-update/per-user-all-defaults/0/1.0.0/automaticupdatesexample_peruseralldefaults.exe. Note how the link points to a location within the folder structure.

When you click the link, the browser downloads the downloader. When run, the downloader downloads the MSI file:

The downloader progress form

When the MSI is downloaded, the downloader starts it:

The installer is started

You follow the on-screen instructions to get the add-in installed. Start Excel to find the add-in there:

The add-ins shows its Ribbon UI

Starting the add-in also starts the updater; check the Details tab of the Task Manager window.

If you prepare another version of the add-in, create a new (or modify existing) setup project, publish it and put the files to the location that the user can access via the URL specified in the Installation URL field, the updater finds the update and shows a Windows notification:

The notification window informing about version 2 available

Clicking the notification shows the updater’s form:

The updater application

Click Update. This downloads the update:

The updater downloads version 2

When the process is complete you get this message:

The updater requires to close the add-in's host application

Click Yes and close Excel. When Excel is closed, the updater starts the installer of version 2. When the installation is complete, Excel starts with the add-in’s version 2 loaded:

Add-in version 2 shows its Ribbon UI

Post a comment

Have any questions? Ask us right now!