Refresh Outlook 2003 Commandbar Menu subitems

Posted on 2011-10-24
Last Modified: 2012-05-12
I have an VSTO project directed at Outlook 2003 that has a dynamic toolbar which is loaded when the NewInspector event fires.  The toolbar has a commandbarpopup that has commandbarbutton's added from a list.  What I want to do is refresh the buttons when adds/deletes are applied to the list.  The commandbarbuttons also have a handler for the click event, so these would need to be removed before the new buttons are added.  My code for loading the buttons is as follows:

                For Each item In m_listoptions
                    btn = mnu.controls.add(Office.MsoControlType.msoControlButton, 1, "", 1, True)
                    With btn
                        .Caption = item.Name.ToString()
                        .Tag = item.Option.ToString()
                    End With

                    AddHandler btn.Click, AddressOf Button_Click

I am using VSTO Visual Studio 2008 targetting Outlook 2003
Question by:inkineu
    LVL 83

    Accepted Solution

    You can add all the btns, that you add to a menu, to a list. And then use the mnu.Controls.Remove(btn) to remove them. You dont need to worry about the handlers.
    LVL 1

    Author Comment

    Sorry for the delay, I'm running into problems with the controls.add statement.  Looks like some of the buttons are not appearing.  I'll need to run it in debug mode to see what's actually happening.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Create high volume marketing opportunities using email signatures with these top 10 DOs and DON'Ts of email signature marketing.
    Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now