none
OnStartupComplete not running for Outlook IDTExtensibility2 based Add-In RRS feed

  • Question

  • Hi all,

    I hope someone can help me with this.  I am trying to write a addin for Outlook but I appear to be stuck.  So for my AddIn opens Outlook when I run it from Visual Studio but none of the Startup or Connection subs appear to run.

    I am developing on the following system:

    Windows 7 (64bit)

    Outlook 2003

    Visual Basic 2010 Express

    I have created the following class:

    #Region "Imports"
    Imports Microsoft.Office
    Imports Microsoft.Office.Core
    Imports Microsoft.Office.Interop
    Imports Extensibility
    Imports System.Runtime.InteropServices
    Imports System.Reflection
    Imports Microsoft.Office.Interop.Outlook
    #End Region

    <GuidAttribute("DED8EBB8-4691-40E8-AF63-D63D242563C1"), _
    ProgIdAttribute("OutlookAddInTemplate.Connect")> _
    Public Class Connect
        Implements Extensibility.IDTExtensibility2
        Dim OutlookApplication As Microsoft.Office.Interop.Outlook.Application
        Dim WithEvents IButton As CommandBarButton
        Private applicationObject As Object
        Private addInInstance As Object

        Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown
            MsgBox("Add-in is OnBeginShutdown")
            OutlookApplication = Nothing
        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("Add-in is OnStartupComplete")
            OutlookApplication = New Outlook.Application
        End Sub

        Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnection
            GC.Collect()
            GC.WaitForPendingFinalizers()
            MsgBox("Add-in is OnDisconnection")
        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
            MsgBox("Add-in is OnConnection")
        End Sub
    End Class

    The project has the following references:

    Extensibility

    Microsoft Office 11.0 Object Library

    Microsoft Outlook 11.0 Object Library

    System

    System.Core

    System.Data

    System.Data.DataSetExtensions

    System.Xml

    System.XML.Linq

    As I stated in the beginning of my post when I run the code Outlook opens but none of the message boxes are displayed.  Therefore I presume that none of the subs are running.  Does anybody know if there is some form or security that could be blocking this or if there is just a mistake in my code?

    I do not get any errors when I run this.

    Any feedback would be most appriecated.

    • Moved by Mark Liu-lxfModerator Monday, February 27, 2012 3:06 AM Outlook issue (From:Visual Basic General)
    Friday, February 24, 2012 11:55 AM

All replies

  • Hi Simon,

    Welcome to the MSDN forum.

    This queue is about Visual Basic. I’m afraid that the topic about Outlook is unsuitable here. For better support, I will move this thread to Outlook for Developers forum.

    Sorry for any inconvenience and have a nice day.


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us

    Monday, February 27, 2012 3:06 AM
    Moderator
  • As far as I know the Express versions of VS do not support COM addins.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Simon Goodson" <=?utf-8?B?U2ltb24gR29vZHNvbg==?=> wrote in message news:5f606548-0831-464f-b31c-a41279bd2104...

    Hi all,

    I hope someone can help me with this.  I am trying to write a addin for Outlook but I appear to be stuck.  So for my AddIn opens Outlook when I run it from Visual Studio but none of the Startup or Connection subs appear to run.

    I am developing on the following system:

    Windows 7 (64bit)

    Outlook 2003

    Visual Basic 2010 Express

    I have created the following class:

    #Region "Imports"
    Imports Microsoft.Office
    Imports Microsoft.Office.Core
    Imports Microsoft.Office.Interop
    Imports Extensibility
    Imports System.Runtime.InteropServices
    Imports System.Reflection
    Imports Microsoft.Office.Interop.Outlook
    #End Region

    <GuidAttribute("DED8EBB8-4691-40E8-AF63-D63D242563C1"), _
    ProgIdAttribute("OutlookAddInTemplate.Connect")> _
    Public Class Connect
        Implements Extensibility.IDTExtensibility2
        Dim OutlookApplication As Microsoft.Office.Interop.Outlook.Application
        Dim WithEvents IButton As CommandBarButton
        Private applicationObject As Object
        Private addInInstance As Object

        Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown
            MsgBox("Add-in is OnBeginShutdown")
            OutlookApplication = Nothing
        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("Add-in is OnStartupComplete")
            OutlookApplication = New Outlook.Application
        End Sub

        Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnection
            GC.Collect()
            GC.WaitForPendingFinalizers()
            MsgBox("Add-in is OnDisconnection")
        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
            MsgBox("Add-in is OnConnection")
        End Sub
    End Class

    The project has the following references:

    Extensibility

    Microsoft Office 11.0 Object Library

    Microsoft Outlook 11.0 Object Library

    System

    System.Core

    System.Data

    System.Data.DataSetExtensions

    System.Xml

    System.XML.Linq

    As I stated in the beginning of my post when I run the code Outlook opens but none of the message boxes are displayed.  Therefore I presume that none of the subs are running.  Does anybody know if there is some form or security that could be blocking this or if there is just a mistake in my code?

    I do not get any errors when I run this.

    Any feedback would be most appriecated.


    Ken Slovak MVP - Outlook
    Monday, February 27, 2012 4:27 PM
    Moderator
  • Hi Ken,

    It doesn't have built in support as it does not have the templates etc.  However I have created all of the bits (as far as I am aware) that one of the provided templates would need.  This has got me to the stage where I can open Outlook.

    Does the code I have provided look right?  If so it could be a problem with the code I have added to replicate the template.  Or is there something obviously wrong with the code?  If I were using the full Visual Studio would you say it looks correct?

    Regards,

    Simon 

    Tuesday, February 28, 2012 9:53 AM
  • Well, I'd certainly make the assembly (the Connect class) visible from COM:
    <GuidAttribute("DED8EBB8-4691-40E8-AF63-D63D242563C1"), _
    ProgIdAttribute("OutlookAddInTemplate.Connect"), ComVisible(True)>
    Public Class Connect
    Are you registering your addin? For it to run and be recognized by Outlook you need to make sure you have registration for LoadBehavior, Description, FriendlyName and CommandLineSafe under an "OutlookAddInTemplate.Connect" key in either HKCU or HKLM.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Simon Goodson" <=?utf-8?B?U2ltb24gR29vZHNvbg==?=> wrote in message news:b6b23f8f-d635-4040-a549-fd093dbd58aa...

    Hi Ken,

    It doesn't have built in support as it does not have the templates etc.  However I have created all of the bits (as far as I am aware) that one of the provided templates would need.  This has got me to the stage where I can open Outlook.

    Does the code I have provided look right?  If so it could be a problem with the code I have added to replicate the template.  Or is there something obviously wrong with the code?  If I were using the full Visual Studio would you say it looks correct?

    Regards,

    Simon 


    Ken Slovak MVP - Outlook
    Tuesday, February 28, 2012 3:21 PM
    Moderator
  • Hi Ken,

    I'll have a go at making the  assembly (the Connect class) visible from COM.  On the 2nd point I have registered the addin.  I'll double check all of the settings and let you know how I get on.

    Regards,

    Simon

    Wednesday, February 29, 2012 12:56 PM