none
Click Office menu item programmatically RRS feed

  • Question

  • Hi,
    We are creating an excel add-in which will add a custom menu (say A) to the excel, which has a few menu items. When a menu item on the custom menu (A) is clicked, we need to programmatically click another menu item in another exisiting menu (say B). In the click event of the menu item in A, I can get the reference to the menu item in menu B. The type is CommandBarButton. How can I programmatically click this menu item in menu B? Is there a method like PerformClick() in case of a Button?
    Kindly suggest.

    Regards,
    Asim.
    Monday, October 20, 2008 3:26 PM

Answers

  • I tried the Execute but it only select the menu (at least in MSProject)
    I found a solution with :

    accDoDefaultAction(null)

    that realize the action on the menu and not only select it.

    hope it helps
    Valéry

    Monday, October 20, 2008 3:47 PM

All replies

  • Well, there's the Execute method for a CommandBarControl you could probably use.

    But why not just call the procedure that button's click event calls?
    Cindy Meister, VSTO/Word MVP
    Monday, October 20, 2008 3:40 PM
    Moderator
  • I tried the Execute but it only select the menu (at least in MSProject)
    I found a solution with :

    accDoDefaultAction(null)

    that realize the action on the menu and not only select it.

    hope it helps
    Valéry

    Monday, October 20, 2008 3:47 PM
  • Thanks. accDoDefaultAction(null) works :)
    Tuesday, October 21, 2008 9:12 AM