Introduced in Excel 2000.
COM Add-ins must be in-process COM servers that support the IDTExtensibility2 interface.
New Project Class Library
Rename the Class1.cs file to Connect.cs
References, Add Reference, Assemblies > Extensions
Add the following code to the Connect.cs:
public class Connect : Object
private object _ApplicationObject;
private object _AddinInstance;
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
this._ApplicationObject = application;
this._AddinInstance = addInInst;
public void OnDisconnection(ext_DisconnectMode disconnectMode, ref System.Array custom)
public void OnAddInsUpdate(ref System.Array custom)
public void OnStartupComplete(ref System.Array custom)
public void OnBeginShutdown(ref System.Array custom)
Select (Project > Properties)
Display the Build tab and tick "Register for COM Interop"
Select (Build > Build Solution)
Installed COM Add-ins
Microsoft Office applications identify COM add-ins by reading from the registry
You can view the registry by going to the Windows start menu, choosing Run, typing regedit and pressing OK.
Microsoft Office COM add-ins appear in two places
Register For Com - will generate a tlb file
They also appear under local machine
Any COM add-ins that are registered under local machine do not appear on the COM addin dialog box and cannot be turned on or off by the user.
For this reason it is good practice not to register them under local machine
COM add-ins should be installed on a per user basis so that the add-in user settings will move with the user should they log onto a different machine.
The (Tools > COM Add-ins) dialog box only displays add-ins that are registered under the HKEY_CURRENT_USER registry key.
Any add-ins that are installed on a machine basis are registered under the HKEY_LOCAL_MACHINE key.
COM add-ins registered for a machine are available to all users but do not appear in the (Tools > COM Add-ins) dialog box.
There must be a key representing the COM Add-in under the Addins key
COM add-ins used by Excel are stored in the following registry key:
When a COM add-in is installed registry entries are created for the Add-in.
This key contains a sub key for each installed COM addin.
The name of the subkey is the ProgID for the COM add-in.
The subkey also contains values that describe the COM add-in friendly name, description and load behaviour.
The load behaviour describes how the add-in will be loaded either:
"loaded at startup" - Bootload = 2 (load on application startup)
"loaded at next startup only" - ConnectFirstTime = 16
"loaded on demand" - DemandLoad = 8 (loaded only when requested by the user)
"Is loaded" - Loaded = 1
"not loaded" - Disconnect = 0
This key has the ProgID of the COM addin.
COM uses this key to create your COM add-in.
The default key created by Visual Studio is the name of the add-in project combined with the name of the class generated in Visual Studio that implements the IDTExtensibility2 interface.
Under this key you will find several values
|Description||String (REG_SZ)||A brief description of the add-in|
|FriendlyName||String (REG_SZ)||The descriptive name that is displayed in the COM add-ins dialog box.|
|LoadBehavior||(DWORD)||The load behaviour of the add-in.|
© 2018 Better Solutions Limited. All Rights Reserved. © 2018 Better Solutions Limited TopPrevNext