COM Add-in

Introduced in Excel 2000.
COM Add-ins must be in-process COM servers that support the Extensibility.IDTExtensibility2 interface.
If you want an add-in to appear in the COM Add-ins dialogs then it must implement this interface.
Creating a COM Add-in for the Visual Basic Editor -


Open Visual Studio 2017.
New Project, Class Library (.NET Framework) Change the Name to "VBACOMAddin"
Change the Location to somewhere on your C drive.
Add three references to this project (Project > Add Reference) References, Add Reference, Assemblies, Framework, Add "System.Windows.Forms"
References, Add Reference, Assemblies, Extensions, Add "Extensibility"
References, Add Reference, COM, Add "Microsoft Visual Basic for Applications Extensibility 5.3" (Version 5.3)
Rename the Class1.cs file to MyConnect.cs.
Add the following interface to the MyConnect.cs file.

namespace VBACOMAddin1 
    public class MyConnect
        public Microsoft.Vbe.Interop.VBE _ApplicationObject;
        public Microsoft.Office.Core.COMAddIn _AddinInstance;

        public void OnConnection(
            object Application,
            Extensibility.ext_ConnectMode ConnectMode,
            object AddInInst,
            ref System.Array custom)
            this._ApplicationObject = (Microsoft.Vbe.Interop.VBE)Application;

            if (this._AddinInstance == null)
                this._AddinInstance = (Microsoft.Office.Core.COMAddIn)AddInInst;
                this._AddinInstance.Object = this;

            switch (ConnectMode)
                case Extensibility.ext_ConnectMode.ext_cm_Startup:
                    // normal execution path - don't initialize just yet, wait for OnStartupComplete to be called by the host.
                case Extensibility.ext_ConnectMode.ext_cm_AfterStartup:
        public void OnDisconnection(
            Extensibility.ext_DisconnectMode RemoveMode,
            ref System.Array custom)
            this._ApplicationObject = null;
            this._AddinInstance = null;
        public void OnAddInsUpdate(ref System.Array custom)
        { }
        public void OnStartupComplete(ref System.Array custom)
        public void OnBeginShutdown(ref System.Array custom)
        { }

        public void InitializeAddIn()
                this._AddinInstance.ProgId + " loaded in VBA editor version " +

Make sure the Guid Id is replaced using (Tools > Create GUID).
Select Build > Build Solution).
At this point no registry entries are added to the registry.
Select (Project > Properties).
Display the Build tab.
Tick the "Register for COM Interop" checkbox (requires admin rights).
Close the Properties window.
Select (Build > Build Solution).
When the solution is built a "TLB" file appears in the "\bin\Debug\" folder.
When the solution is built the RegAsm tool automatically runs.
The RegAsm tool adds the necessary class and interface information to the registry.

C:\Windows\Microsoft.NET\Framework\v4.0.30319\ RegAsm /codebase VBACOMAddin.dll 

Registry Keys - COM Add-in

Microsoft Office COM add-ins are identified by reading from the registry.
You can view the registry by going to the Windows start menu, choosing Run, typing regedit and pressing OK.
There must be a key representing the COM Add-in under the Addins key:
64 Bit Office - HKEY_CURRENT_USER\Software\Microsoft\VBA\VBE\7.1\Addins64\
32 Bit Office - HKEY_CURRENT_USER\Software\Microsoft\VBA\VBE\7.1\Addins\

(String)(Default) - (value not set)
(String) Description - A Long Description
(String) FriendlyName - VBACOMAddin
(DWord) LoadBehavior - 0

Description - A brief description of the add-in.
FriendlyName - A user friendly name that is displayed in the COM add-ins dialog box.
Load Behavior - The load behaviour of the add-in.

© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrev