Export (0) Print
Expand All
Cut
Run
Expand Minimize

OnConnection Method

Visual Studio .NET 2003

Occurs when an Add-in is loaded into the environment.

[Visual Basic .NET]
Public Sub OnConnection( _
   ByVal Application As Object, _
   ByVal ConnectMode As ext_ConnectMode, _
   ByVal AddInInst As Object, _
   ByVal custom() As Variant _
) 
[Visual Basic 6]
Sub OnConnection( _
   ByVal Application As Object, _
   ByVal ConnectMode As ext_ConnectMode, _
   ByVal AddInInst As Object, _
   ByVal custom() As Variant _
) 
[C++]
HRESULT __stdcall OnConnection(
   IDispatch* Application,
   ext_ConnectMode ConnectMode,
   IDispatch* AddInInst,
   SAFEARRAY** custom
);
[C#]
void OnConnection(
   object Application,
   ext_ConnectMode ConnectMode,
   object AddInInst,
   object[] custom
);
[JScript .NET]
public function OnConnection(
   Application : Object,
   ConnectMode : ext_ConnectMode,
   AddInInst : Object,
   custom : Object[]
)

Parameters

Application
The top-level extensibility object.
ConnectMode
A ext_cm constant specifying how the Add-in was loaded.
AddInInst
An AddIn object representing the instance of the Add-in.
custom
An array of Variants that you can use to provide additional data.

Remarks

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.

Example

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

See Also

OnAddInsUpdate Method | OnBeginShutdown Method | OnDisconnection Method | OnStartupComplete Method

Applies To: IDTExtensibility2 Interface

Show:
© 2014 Microsoft