COM Add-on

G

Guest

hi there,

i got a COM add-in and it loads fine in to outlook but if i add the
following line of code so that i can call a function from an outlook form it
doesn't load at all?

application.COMAddIns.Item("DMCRM.Connect").Object = Me

i got this info from http://support.microsoft.com/?kbid=240768

My code is below and the function i am trying to call is tester

thanks a lot any help please

Jonathan

Imports Microsoft.Office.Core
Imports Microsoft.Office.Interop.Outlook
Imports Extensibility
Imports System.Runtime.InteropServices


#Region " Read me for Add-in installation and setup information. "
' When run, the Add-in wizard prepared the registry for the Add-in.
' At a later time, if the Add-in becomes unavailable for reasons such as:
' 1) You moved this project to a computer other than which is was
originally created on.
' 2) You chose 'Yes' when presented with a message asking if you wish to
remove the Add-in.
' 3) Registry corruption.
' you will need to re-register the Add-in by building the DMCRMSetup project
' by right clicking the project in the Solution Explorer, then choosing
install.
#End Region

<GuidAttribute("572C0332-5D4C-4BF3-B8E4-943F860399B8"),
ProgIdAttribute("DMCRM.Connect")> _
Public Class Connect

#Region "Var"

Implements Extensibility.IDTExtensibility2

'
'
'
Dim applicationObject As Object
Dim addInInstance As Object


#End Region

#Region "COM add-in"

Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnBeginShutdown
On Error Resume Next
' Notify the user you are shutting down, and delete the button.
MsgBox("Our custom Add-in is unloading.")

End Sub

Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnAddInsUpdate
'
End Sub

Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete
MsgBox("Our custom Add-in is loading.")

End Sub

Public Sub OnDisconnection(ByVal RemoveMode As
Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnDisconnection
On Error Resume Next

If RemoveMode <>
Extensibility.ext_DisconnectMode.ext_dm_HostShutdown Then _
Call OnBeginShutdown(custom)

applicationObject = Nothing
End Sub

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 = application
addInInstance = addInInst

' If you aren't in startup, manually call OnStartupComplete.
If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup)
Then _
Call OnStartupComplete(custom)



End Sub

#End Region

Public Function Tester()
MsgBox("testing 1 2 3")
End Function

End Class
 
J

Jay B. Harlow [MVP - Outlook]

Dorling,
I answered your question on OutlookCode.com also.

Creating a bear bones "Shared Add-in" in VS.NET 2003, I needed to cast the
"application" parameter to OnConnection to a typed variable (instead of
Object) to get the assignment to work.

Something like:


Imports Microsoft.Office.Core
imports Extensibility
Imports System.Runtime.InteropServices

Imports Outlook = Microsoft.Office.Interop.Outlook


#Region " Read me for Add-in installation and setup information. "
' When run, the Add-in wizard prepared the registry for the Add-in.
' At a later time, if the Add-in becomes unavailable for reasons such as:
' 1) You moved this project to a computer other than which is was
originally created on.
' 2) You chose 'Yes' when presented with a message asking if you wish to
remove the Add-in.
' 3) Registry corruption.
' you will need to re-register the Add-in by building the OutlookAddinSetup
project
' by right clicking the project in the Solution Explorer, then choosing
install.
#End Region

<GuidAttribute("ACD4BD7E-A8EC-4D08-B556-EF03224FA058"), _
ProgIdAttribute("OutlookAddin.Connect"), _
Public Class Connect

Implements Extensibility.IDTExtensibility2

Dim applicationObject As Object
Dim addInInstance As Object


Protected Sub OnBeginShutdown(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnBeginShutdown
End Sub

Protected Sub OnAddInsUpdate(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnAddInsUpdate
End Sub

Protected Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete
End Sub

Protected Sub OnDisconnection(ByVal RemoveMode As
Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnDisconnection
End Sub

Protected 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 = application
addInInstance = addInInst
Try
Dim app As Outlook.Application = DirectCast(application,
Outlook.Application)
app.COMAddIns.Item("OutlookAddin.Connect").Object = Me
Catch ex As Exception
MsgBox(ex.ToString(), MsgBoxStyle.Exclamation Or
MsgBoxStyle.OKOnly, "Outlook Addin")
End Try
End Sub

Public Sub Test()
MsgBox("Test", MsgBoxStyle.Information Or MsgBoxStyle.OKOnly,
"Outlook Addin")
End Sub

End Class

It appears when you attempt to use late binding on the statement:

application.COMAddIns.Item("DMCRM.Connect").Object = Me

That VB.NET has problems with it.

Hope this helps
Jay

| hi there,
|
| i got a COM add-in and it loads fine in to outlook but if i add the
| following line of code so that i can call a function from an outlook form
it
| doesn't load at all?
|
| application.COMAddIns.Item("DMCRM.Connect").Object = Me
|
| i got this info from http://support.microsoft.com/?kbid=240768
|
| My code is below and the function i am trying to call is tester
|
| thanks a lot any help please
|
| Jonathan
|
| Imports Microsoft.Office.Core
| Imports Microsoft.Office.Interop.Outlook
| Imports Extensibility
| Imports System.Runtime.InteropServices
|
|
| #Region " Read me for Add-in installation and setup information. "
| ' When run, the Add-in wizard prepared the registry for the Add-in.
| ' At a later time, if the Add-in becomes unavailable for reasons such as:
| ' 1) You moved this project to a computer other than which is was
| originally created on.
| ' 2) You chose 'Yes' when presented with a message asking if you wish to
| remove the Add-in.
| ' 3) Registry corruption.
| ' you will need to re-register the Add-in by building the DMCRMSetup
project
| ' by right clicking the project in the Solution Explorer, then choosing
| install.
| #End Region
|
| <GuidAttribute("572C0332-5D4C-4BF3-B8E4-943F860399B8"),
| ProgIdAttribute("DMCRM.Connect")> _
| Public Class Connect
|
| #Region "Var"
|
| Implements Extensibility.IDTExtensibility2
|
| '
| '
| '
| Dim applicationObject As Object
| Dim addInInstance As Object
|
|
| #End Region
|
| #Region "COM add-in"
|
| Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements
| Extensibility.IDTExtensibility2.OnBeginShutdown
| On Error Resume Next
| ' Notify the user you are shutting down, and delete the button.
| MsgBox("Our custom Add-in is unloading.")
|
| End Sub
|
| Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements
| Extensibility.IDTExtensibility2.OnAddInsUpdate
| '
| End Sub
|
| Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
| Extensibility.IDTExtensibility2.OnStartupComplete
| MsgBox("Our custom Add-in is loading.")
|
| End Sub
|
| Public Sub OnDisconnection(ByVal RemoveMode As
| Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements
| Extensibility.IDTExtensibility2.OnDisconnection
| On Error Resume Next
|
| If RemoveMode <>
| Extensibility.ext_DisconnectMode.ext_dm_HostShutdown Then _
| Call OnBeginShutdown(custom)
|
| applicationObject = Nothing
| End Sub
|
| 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 = application
| addInInstance = addInInst
|
| ' If you aren't in startup, manually call OnStartupComplete.
| If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup)
| Then _
| Call OnStartupComplete(custom)
|
|
|
| End Sub
|
| #End Region
|
| Public Function Tester()
| MsgBox("testing 1 2 3")
| End Function
|
| End Class
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top