Occurs when an Add-in is loaded into the environment.
Public Sub OnConnection( _ ByVal Application As Object, _ ByVal ConnectMode As ext_ConnectMode, _ ByVal AddInInst As Object, _ ByVal custom() As Variant _ )
Sub OnConnection( _ ByVal Application As Object, _ ByVal ConnectMode As ext_ConnectMode, _ ByVal AddInInst As Object, _ ByVal custom() As Variant _ )
HRESULT __stdcall OnConnection( IDispatch* Application, ext_ConnectMode ConnectMode, IDispatch* AddInInst, SAFEARRAY** custom );
void OnConnection( object Application, ext_ConnectMode ConnectMode, object AddInInst, object custom );
public function OnConnection( Application : Object, ConnectMode : ext_ConnectMode, AddInInst : Object, custom : Object )
- The top-level extensibility object.
- A ext_cm constant specifying how the Add-in was loaded.
- An AddIn object representing the instance of the Add-in.
- An array of Variants that you can use to provide additional data.
OnConnection is a method that, when its host interface (IDTExtensibility2) is implemented, acts as an event that occurs when an Add-in is loaded. This can occur when:
- A user loads the Add-in through the Add-In Manager dialog box.
- An Add-in is marked to start when its host application loads.
- The Connect property of a corresponding AddIn object is set to True.
Note that this code works only in an Add-In project, not in macros.
Imports Microsoft.Office.Core imports Extensibility imports System.Runtime.InteropServices Imports EnvDTE <GuidAttribute("B25D9733-A1B2-420D-8F6B-478E2B051C83"), ProgIdAttribute("MyAddin1.Connect")> _ Public Class Connect Implements Extensibility.IDTExtensibility2 Dim applicationObject As EnvDTE.DTE Dim addInInstance as EnvDTE.AddIn Public Sub OnConnection(ByVal application As Object, ByVal connectMode As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnConnection applicationObject = CType(application, EnvDTE.DTE) addInInstance = CType(addInInst, EnvDTE.AddIn) End Sub End Class
Applies To: IDTExtensibility2 Interface