locked
c#: Show dynamic menu defined in XML from the program RRS feed

  • Question

  • I have Outlook Addin that has buttons defined in XML file. This line is from that file.

      <dynamicMenu id="idSaveAttachments" getLabel="GetLabel" image="SaveAttachmentsIcon" size="large" getScreentip="getScreenTooltip" invalidateContentOnDrop="true" getContent="GetAttachmentsMenu" getEnabled="GetEnabled"/>

    As I understand it defines a button and when it is clicked GetAttachmentsMenu function is called that fills the menu. It works perfectly.

    Currently I want to show that menu from code. I can call GetAttachmentsMenu function and get the content of menu in XML format but I have no idea how to show the menu.

    How is it possible? Are there general methods to invoke this kind of XML based UI items from the program?

    It is used Ribbon UI model.

     have tried this code:

        Outlook.Application applicationObject = Globals.MyThisAddIn.Application;
        Outlook.Explorer  oExp = (Outlook.Explorer)applicationObject.ActiveExplorer();
        oExp.CommandBars.ExecuteMso("idSaveAttachments");

    But I am getting error:

    'Value does not fall within the expected range.'


    Tuesday, April 10, 2018 10:05 AM

All replies

  • Hi AshotMinasyan,

    Thank you for posting here.

    According to your question is more related to office, I will move it to Visual Studio Tools for Office (VSTO) forum for suitable support.

    The CLR Forum discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection. Also discuss all the other Microsoft libraries that are built on or extend the .NET Framework, including Managed Extensibility Framework (MEF), Charting Controls, CardSpace, Windows Identity Foundation (WIF), Point of Sale (POS), Transactions.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 11, 2018 2:23 AM
  • Hello AshotMinasyan,

     >>I can call GetAttachmentsMenu function and get the content of menu in XML format but I have no idea how to show the menu.

    How do you call the GetAttachmentsMenu function? What result do you want? Do you want to simulate clicking on the dynamicMenu to show its content via programme? If so, why do you need do this?

    >>oExp.CommandBars.ExecuteMso("idSaveAttachments");

    ExecuteMso is designed to execute built-in controls and your dynamicMenu is a custom control. 

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, April 12, 2018 10:18 AM