Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

outlook add-on button

Posted on 2009-04-07
6
Medium Priority
?
276 Views
Last Modified: 2013-11-26
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
0
Comment
Question by:qwerty360
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 24088085
Hi, qwerty360.

Create a button where?  A form, the ribbon, in a pane, etc.?
0
 

Author Comment

by:qwerty360
ID: 24088410
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

0
 
LVL 76

Expert Comment

by:David Lee
ID: 24134203
Sorry to be slow getting back to you.

Try changing the declaration of display_message to

    Public Sub display_message()
0
Cloud Training Guides

FREE GUIDES: In-depth and hand-crafted Linux, AWS, OpenStack, DevOps, Azure, and Cloud training guides created by Linux Academy instructors and the community.

 

Author Comment

by:qwerty360
ID: 24138313

I changed it to  " Public Sub display_message()"  but still nothing happens when I click on the menu item
0
 

Accepted Solution

by:
qwerty360 earned 0 total points
ID: 24146990
I got it to work using "WithEvents" in the following code
   Private WithEvents myMenuItem As Office.CommandBarButton
    Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
        Try
            Dim ActionsCmdBar As Office.CommandBar = Me.Application.Explorers(1).CommandBars("Actions")
            Dim cbb As Office.CommandBarControl
            For Each cbb In ActionsCmdBar.Controls
                If cbb.Caption = "My Menu Item" Then
                    cbb.Delete()
                End If
            Next
            myMenuItem = ActionsCmdBar.Controls.Add(Office.MsoControlType.msoControlButton)
            myMenuItem.Caption = "My Menu Item"
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
 
    Private Sub myMenuItem_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, _
    ByRef CancelDefault As Boolean) Handles myMenuItem.Click
        Try
            System.Windows.Forms.MessageBox.Show("test")
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
 
    End Sub

Open in new window

0
 
LVL 76

Expert Comment

by:David Lee
ID: 24152936
Good deal  Glad you have a solution.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question