Search code examples
c#outlookoutlook-addinoutlook-redemptionsplit-button

Programmatically invoking the drop down item in C# form Outlook Add-in


I have a outlook add-in from which i want to invoke Ribbon Split button's drop down item using Redemption . This split button is a custom button created from other add-in. I want to access in my add-in. For detailed explanation check the below link.Invoking the Ribbon Split button using redemption When i tried accessing I am getting same error. Can some one help me to solve this problem. Here i am trying to invoke drop down item where in the other post that was trying to invoke button of the split button and moreover i have attached image which is very clear. Check the image in the link. (The link post was already posted by some one else in the stack overflow long back)

enter image description here


Solution

  • You cannot access buttons freely in the Office Ribbon, as was possible with the CommandBars interface - no matter what the programming language. This was a design decision on the part of Microsoft.

    There are provisions for accessing the built-in controls provided by the Office application, as have been mentioned by others: CommandBars.ExecuteMso and the Accessibility APIs. These do not work for custom buttons, however.

    It is possible to "share" another add-in's Ribbon controls, provided that add-in has used a namespace and the idQ attribute for the controls it shares. This does not enable your code to run the other add-ins code, however. (See this MSDN article: https://msdn.microsoft.com/en-us/library/aa338202(v=office.12))

    The only possibility, but it's not a reliable one, is to use SendKeys (emulate the user typing) to send the Alt+keyboard shortcut combination for the command. The reason this is not reliable is because Office can alter the shortcut at any time, if it conflicts with any other shortcut present at that particular moment in the UI.