Dim m_oAddin As olAddin
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
Dim oApp As myOutlook.Application
Dim oType As Type
Dim GetProgID As Object
Dim MyProgID As String
Dim oArgs As Object()
Try
m_oAddin = New olAddin
'Use InvokeMember to get ProgID of addInInst object
oType = addInInst.GetType
GetProgID = oType.InvokeMember("ProgID", _
BindingFlags.Public Or BindingFlags.GetField Or BindingFlags.GetProperty, _
Nothing, _
addInInst, _
oArgs)
MyProgID = CType(GetProgID, String)
oApp = CType(application, myOutlook.Application)
'Don't call InitHandler if Explorers.Count = 0 and Inspectors.Count = 0
If oApp.Explorers.Count = 0 And oApp.Inspectors.Count = 0 Then
Exit Sub
End If
' Initialize COMAddin object with this connect object to allow
' external clients to get access to exposed features
oApp.COMAddIns.Item(MyProgID.ToString).Object = Me
'Call InitHandler
m_oAddin.InitHandler(oApp, MyProgID)
Catch ex As SystemException
End Try
End Sub
|