excelexcel-addins

Automation Excel add-in registry location


I have just changed my development environment (I installed a new Windows version 10 on a new machine with the Office Suite 2016). I am trying to expose some Excel dlls through an Automation Add-in procedure (call them namespace Test and class XlAddin, which I implemented in C#). I expect to retrieve these add-ins in Excel by looking at:

Excel > File > Options > Add-ins > Manage 'Excel Add-ins' > Go > Automation

and find it listed as Test.XlAddin among the various Automation Servers. It does not work in my new environment, although I did not amend my COM registration/unregistration code and my installer code.

In my previous environment, the GUID key for Test.XlAddin was registered as Computer\HKEY_CLASSES_ROOT\CLSID\{GUID key}

In my new environnement, the GUID key for Test.XlAddin is registered as Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Test.XlAddin\CLSID\{GUID key}

Can one see any reason why this could be happening and what is the actual and correct way to register an Excel add-in and whether this change of registry location might be the cause of this add-in's not showing up in the Excel list of automation servers?


Solution

  • The discrepancy in registry paths between your old and new environments could be causing the Excel add-in to not show up. The recommended registry path for Excel add-ins using COM automation is HKEY_CLASSES_ROOT\CLSID\{GUID key}.

    // C# code snippet to register a COM Excel add-in
    using Microsoft.Win32;
    
    public static void RegisterComObject(string clsid, string assemblyPath)
    {
        RegistryKey baseKey = Registry.ClassesRoot.CreateSubKey("CLSID\\" + clsid);
        baseKey.SetValue(null, "Your Add-in Description");
        baseKey.CreateSubKey("InprocServer32").SetValue("CodeBase", assemblyPath);
    }
    

    Note: Always remember to run as administrator when you're editing the Windows Registry. Make sure to replace clsid and assemblyPath with your specific GUID and DLL path, respectively.