Avatar of CADMatch
CADMatch

asked on 

Outlook Add-in Commandbar Problems

I have the following problem with an Add-in I’m writing for outlook in VB.NET. I add an command button to the toolbar of the new mail window when the user creates a new mail. Now this works correctly, the button shows up and the events of the inspector object are fired correctly. The only problem is that the click event of the command button won't fire. If i use the same code to create a button in the main window it fires correctly. Any help would be greatly appreciated.

***Code***
Public Class ThisApplication

    Private WithEvents oInspectors As Outlook.Inspectors
    Private WithEvents oSendBulk As Office.CommandBarButton
    Private WithEvents oMail As Outlook.MailItem

    Private Sub ThisApplication_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup

        oInspectors = Me.Inspectors

    End Sub

    Private Sub oInspectors_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector) Handles oInspectors.NewInspector

        'If the new inspector was created on an new mail event create the new toolbar button

        If Inspector.CurrentItem.class = Outlook.OlObjectClass.olMail Then

            'Create the toolbar button if it doesn't excist yet

            Try

            oButton = Inspector.CommandBars("Tools").Controls("Knopje")

            Catch

            oButton = Inspector.CommandBars("Tools").Controls.Add(, , , , True)

            With oButton
            .Caption = "Knopje"
            End With

            End Try

            oMail = Inspector.CurrentItem

        End If

    End Sub




    Private Sub oSendBulk_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean) Handles oSendBulk.Click
        MsgBox("Boing")
    End Sub
End Class
Visual Basic.NET

Avatar of undefined
Last Comment
theGhost_k8
Avatar of theGhost_k8
theGhost_k8
Flag of India image

you should check for 2 properties
.onaction and .TAG
Avatar of theGhost_k8
theGhost_k8
Flag of India image

oButton .OnAction is required i think
Avatar of theGhost_k8
theGhost_k8
Flag of India image

obutton need to be a global var, i assume....it is
Avatar of CADMatch
CADMatch

ASKER

Sorry, i cut the code that's not related to this problem from the sample code. Where oButton is used it should be oSendBulk.
ASKER CERTIFIED SOLUTION
Avatar of theGhost_k8
theGhost_k8
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo