COM Add-on

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dorling

    #1

    COM Add-on

    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.COM AddIns.Item("DM CRM.Connect").O bject = 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.Offic e.Core
    Imports Microsoft.Offic e.Interop.Outlo ok
    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.I DTExtensibility 2

    '
    '
    '
    Dim applicationObje ct As Object
    Dim addInInstance As Object


    #End Region

    #Region "COM add-in"

    Public Sub OnBeginShutdown (ByRef custom As System.Array) Implements
    Extensibility.I DTExtensibility 2.OnBeginShutdo wn
    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.I DTExtensibility 2.OnAddInsUpdat e
    '
    End Sub

    Public Sub OnStartupComple te(ByRef custom As System.Array) Implements
    Extensibility.I DTExtensibility 2.OnStartupComp lete
    MsgBox("Our custom Add-in is loading.")

    End Sub

    Public Sub OnDisconnection (ByVal RemoveMode As
    Extensibility.e xt_DisconnectMo de, ByRef custom As System.Array) Implements
    Extensibility.I DTExtensibility 2.OnDisconnecti on
    On Error Resume Next

    If RemoveMode <>
    Extensibility.e xt_DisconnectMo de.ext_dm_HostS hutdown Then _
    Call OnBeginShutdown (custom)

    applicationObje ct = Nothing
    End Sub

    Public Sub OnConnection(By Val application As Object, ByVal connectMode
    As Extensibility.e xt_ConnectMode, ByVal addInInst As Object, ByRef custom As
    System.Array) Implements Extensibility.I DTExtensibility 2.OnConnection
    applicationObje ct = application
    addInInstance = addInInst

    ' If you aren't in startup, manually call OnStartupComple te.
    If (connectMode <> Extensibility.e xt_ConnectMode. ext_cm_Startup)
    Then _
    Call OnStartupComple te(custom)



    End Sub

    #End Region

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

    End Class


  • Jay B. Harlow [MVP - Outlook]

    #2
    Re: COM Add-on

    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
    "applicatio n" parameter to OnConnection to a typed variable (instead of
    Object) to get the assignment to work.

    Something like:


    Imports Microsoft.Offic e.Core
    imports Extensibility
    Imports System.Runtime. InteropServices

    Imports Outlook = Microsoft.Offic e.Interop.Outlo ok


    #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 OutlookAddinSet up
    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.I DTExtensibility 2

    Dim applicationObje ct As Object
    Dim addInInstance As Object


    Protected Sub OnBeginShutdown (ByRef custom As System.Array) Implements
    Extensibility.I DTExtensibility 2.OnBeginShutdo wn
    End Sub

    Protected Sub OnAddInsUpdate( ByRef custom As System.Array) Implements
    Extensibility.I DTExtensibility 2.OnAddInsUpdat e
    End Sub

    Protected Sub OnStartupComple te(ByRef custom As System.Array) Implements
    Extensibility.I DTExtensibility 2.OnStartupComp lete
    End Sub

    Protected Sub OnDisconnection (ByVal RemoveMode As
    Extensibility.e xt_DisconnectMo de, ByRef custom As System.Array) Implements
    Extensibility.I DTExtensibility 2.OnDisconnecti on
    End Sub

    Protected Sub OnConnection(By Val application As Object, ByVal
    connectMode As Extensibility.e xt_ConnectMode, ByVal addInInst As Object,
    ByRef custom As System.Array) Implements
    Extensibility.I DTExtensibility 2.OnConnection
    applicationObje ct = application
    addInInstance = addInInst
    Try
    Dim app As Outlook.Applica tion = DirectCast(appl ication,
    Outlook.Applica tion)
    app.COMAddIns.I tem("OutlookAdd in.Connect").Ob ject = Me
    Catch ex As Exception
    MsgBox(ex.ToStr ing(), MsgBoxStyle.Exc lamation Or
    MsgBoxStyle.OKO nly, "Outlook Addin")
    End Try
    End Sub

    Public Sub Test()
    MsgBox("Test", MsgBoxStyle.Inf ormation Or MsgBoxStyle.OKO nly,
    "Outlook Addin")
    End Sub

    End Class

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

    application.COM AddIns.Item("DM CRM.Connect").O bject = Me

    That VB.NET has problems with it.

    Hope this helps
    Jay

    "dorling" <dorling@discus sions.microsoft .com> wrote in message
    news:A6810874-2DB2-43E3-B160-CA0B98EEA0F5@mi crosoft.com...
    | 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.COM AddIns.Item("DM CRM.Connect").O bject = 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.Offic e.Core
    | Imports Microsoft.Offic e.Interop.Outlo ok
    | 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.I DTExtensibility 2
    |
    | '
    | '
    | '
    | Dim applicationObje ct As Object
    | Dim addInInstance As Object
    |
    |
    | #End Region
    |
    | #Region "COM add-in"
    |
    | Public Sub OnBeginShutdown (ByRef custom As System.Array) Implements
    | Extensibility.I DTExtensibility 2.OnBeginShutdo wn
    | 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.I DTExtensibility 2.OnAddInsUpdat e
    | '
    | End Sub
    |
    | Public Sub OnStartupComple te(ByRef custom As System.Array) Implements
    | Extensibility.I DTExtensibility 2.OnStartupComp lete
    | MsgBox("Our custom Add-in is loading.")
    |
    | End Sub
    |
    | Public Sub OnDisconnection (ByVal RemoveMode As
    | Extensibility.e xt_DisconnectMo de, ByRef custom As System.Array) Implements
    | Extensibility.I DTExtensibility 2.OnDisconnecti on
    | On Error Resume Next
    |
    | If RemoveMode <>
    | Extensibility.e xt_DisconnectMo de.ext_dm_HostS hutdown Then _
    | Call OnBeginShutdown (custom)
    |
    | applicationObje ct = Nothing
    | End Sub
    |
    | Public Sub OnConnection(By Val application As Object, ByVal connectMode
    | As Extensibility.e xt_ConnectMode, ByVal addInInst As Object, ByRef custom
    As
    | System.Array) Implements Extensibility.I DTExtensibility 2.OnConnection
    | applicationObje ct = application
    | addInInstance = addInInst
    |
    | ' If you aren't in startup, manually call OnStartupComple te.
    | If (connectMode <> Extensibility.e xt_ConnectMode. ext_cm_Startup)
    | Then _
    | Call OnStartupComple te(custom)
    |
    |
    |
    | End Sub
    |
    | #End Region
    |
    | Public Function Tester()
    | MsgBox("testing 1 2 3")
    | End Function
    |
    | End Class
    |
    |


    Comment

    Working...