Logo
INFO: Registry entries to register an add-in for the VBA editor of Office for the current user without admin rights.

Author: Carlos J. Quintero (Microsoft MVP) Applies to: Microsoft Office 64-bit
Date: September 2012   Microsoft Office 32-bit
       
Introduction

This article explains the Windows Registry entries required to register an add-in created with the .NET Framework for the VBA editor of Microsoft Office for the current user without requiring admin rights.

More information

The VBA editor of Microsoft Office supports COM-based add-ins, so to register a dll as an add-in for such host two registrations are required:

  • Register the dll as add-in for the VBA editor.
  • Register the dll as COM component.

1. Registration as add-in for the VBA editor

To register an add-in for the VBA editor of Microsoft Office, a registry key with the ProgId of the Connect class of the add-in used in the COM registration (for example, "MyVBAAddIn.Connect") must be created under the following registry key:

  • For 32-bit versions of Microsoft Office: HKEY_CURRENT_USER\Software\Microsoft\VBA\VBE\6.0\Addins
  • For 64-bit versions of Microsoft Office: HKEY_CURRENT_USER\Software\Microsoft\VBA\VBE\6.0\Addins64

Important: Notice that add-ins are registered for the current user (using the HKEY_CURRENT_USER hive), not for all users (the HKEY_LOCAL_MACHINE hive is ignored by the VBA editor when looking for add-ins). This means that a setup can not install an add-in for all the users of the machine.

Under the registry key with the ProgId, the following values must be created:

Name Type Value Note
FriendlyName REG_SZ My VBA Add-in  
Description REG_SZ My VBA Add-in description  
LoadBehavior DWORD 32-bit 3 This is the value to load the add-in on startup

So, for Microsoft Office 32-bit the registry entries would be:

Language: Text   Copy Code Copy Code (IE only)
HKEY_CURRENT_USER\Software\Microsoft\VBA\VBE\6.0\Addins\MyVBAAddin.Connect
   FriendlyName = My VBA Add-in
   Description = My VBA Add-in description
   LoadBehavior = 3

And for Microsoft Office 64-bit the registry entries would be:

Language: Text   Copy Code Copy Code (IE only)
HKEY_CURRENT_USER\Software\Microsoft\VBA\VBE\6.0\Addins64\MyVBAAddin.Connect
   FriendlyName = My VBA Add-in
   Description = My VBA Add-in description
   LoadBehavior = 3

2. Registration as COM component

COM-registration is normally achieved with some tool like regsrv32.exe for COM-dlls and regasm.exe for .NET dlls registered for COM Interop. These tools require admin rights because they write registry entries in the HKEY_LOCAL_MACHINE (to register the COM component to all the users of the machine). However, since the registration of the dll as add-in for the VBA editor can be done only for the current user, performing COM registration only for the current user (and not for all users) brings these two advantages:

  • The setup would not require admin rights (as long as the dll is copied to some per-user folder).
  • It avoids the following issue: if a non-admin user needs to install an add-in whose setup requires admin rights, when an admin user installs it for her, she doesn't see the add-in, because the setup registered the add-in in the HKEY_CURRENT_USER of the admin user. This same problem happens with VB6 add-ins (see the MSDN Knowledge Base article BUG: Add-Ins Only Visible to the User Who Installs VB).

To register a .NET dll as COM component for the current user (without requiring admin rights), some registry entries must be created for each class of the dll that must be registered (the Connect class, and the classes of userdocuments/usercontrols hosted in toolwindows). Those classes must be Public and have the System.Runtime.InteropServices.ComVisible(True) attribute (see the article HOWTO: Create a toolwindow for the VBA editor of Office from an add-in with Visual Studio .NET.). For each class the following data is required:

  • CLSID of the class. This value can be set with the System.Runtime.InteropServices.Guid attribute applied to the class.
  • ProgId of the class. This value can be set with the System.Runtime.InteropServices.ProgId attribute applied to the class.

Given, for example, the following values for the Connect class:

  • Assembly strong name: MyVBAAddin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=869cad219d7a35e2
  • Class name:  MyVBAAddin.Connect
  • ProgId: MyVBAAddin.Connect
  • CLSID: {2CA1C920-2D5E-3E17-86D7-24DEB9303A3E}
  • .NET Framework version: v2.0.50727

Then the registry entries would be the following:

Language: Text   Copy Code Copy Code (IE only)
HKEY_CURRENT_USER\Software\Classes\MyVBAAddin.Connect
   (default) = MyVBAAddin.Connect
HKEY_CURRENT_USER\Software\Classes\MyVBAAddin.Connect\CLSID
   (default) = {2CA1C920-2D5E-3E17-86D7-24DEB9303A3E}

HKEY_CURRENT_USER\Software\Classes\CLSID\{2CA1C920-2D5E-3E17-86D7-24DEB9303A3E}
   (default) = MyVBAAddin.Connect
HKEY_CURRENT_USER\Software\Classes\CLSID\{2CA1C920-2D5E-3E17-86D7-24DEB9303A3E}\InProcServer32
   (default) = mscoree.dll
   Assembly = MyVBAAddin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=869cad219d7a35e2
   Class = MyVBAAddin.Connect
   Codebase = file:///<path>/MyVBAAddin.DLL
   RuntimeVersion = v2.0.50727
   ThreadingModel = Both
HKEY_CURRENT_USER\Software\Classes\CLSID\{2CA1C920-2D5E-3E17-86D7-24DEB9303A3E}\ProgId
   (default) = MyVBAAddin.Connect

Related articles

Top