Add-in with C#

To create a VBE add-in for the Visual Basic Editor you can use C#.
Create a [[COM Add-in]] that implements the IDTExtensibility2 interface.


Creating

Open Visual Studio 2022 as Administrator.
New Project - C#, Windows, Library.
Choose "Class Library (.NET Framework)"
Change the Name to "VBECOMAddin".
Change the Location to somewhere on your C drive.
Check the .NET Framework version is correct and press OK.
Rename the Class1.cs file to MyConnect.cs.
Add four references to this project, (Project > Add Reference).
(1) Assemblies, Framework: "System.Windows.Forms"
(2) COM, Type Libraries: "Microsoft Office 16.0 Object Library".
(3) COM: Type Libraries: "Microsoft Visual Basic for Applications Extensibility 5.3" (VBIDE)
(4) COM: Type Libraries: "Microsoft Add-in Designer" (Extensibility)
Remove the default class.
Add the following class underneath the interface in the MyConnect.cs file.

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.
Project Properties
Build, Platform Target x64
Open "AssemblyInfo.cs"

When the solution is built the RegAsm tool WILL NOT RUN automatically.
The RegAsm tool adds the necessary class and interface information to the registry.
You need to make sure you opened Visual Studio as Administrator.
Tools > Command Line > Developer Command Prompt

"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe" /codebase /tlb VBEAddin.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\6.0\Addins64\

(String)(Default) - (value not set)

(String) Description - VBACOMAddin

(String) FriendlyName - VBACOMAddin

(DWord) LoadBehavior - 3

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.


Visual Basic Editor

(Tools > Addin Manager)


© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext