Link to home
Start Free TrialLog in
Avatar of qwerty360
qwerty360

asked on

outlook add-on button

Using VB.net how can I create a button in an outlook add-on to outllook 2007 and hook it to a Click event that calls a function
Avatar of David Lee
David Lee
Flag of United States of America image

Hi, qwerty360.

Create a button where?  A form, the ribbon, in a pane, etc.?
Avatar of qwerty360
qwerty360

ASKER

Acutally I am adding a menu item under the "Actions" menu. I was able to add a menu item but I am having trouble now adding an onclick kind of event. I tried the OnAction property but it does not seem to work. Please see the atached code snippet. Thanks.
    Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
        Dim ActionsCmdBar As Office.CommandBar = Me.Application.Explorers(1).CommandBars("Actions")
        Dim myMenuItem As Office.CommandBarButton = ActionsCmdBar.Controls.Add(Office.MsoControlType.msoControlButton)
        myMenuItem.Caption = "My Menu Item"
        myMenuItem.OnAction = "display_message"
    End Sub
 
    Sub display_message()
        Microsoft.VisualBasic.MsgBox("test")
    End Sub

Open in new window

Sorry to be slow getting back to you.

Try changing the declaration of display_message to

    Public Sub display_message()

I changed it to  " Public Sub display_message()"  but still nothing happens when I click on the menu item
ASKER CERTIFIED SOLUTION
Avatar of qwerty360
qwerty360

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Good deal  Glad you have a solution.