none
Hello - Ribbon.xml, it's IRibbonExtensibility create method in ThisAddIn.cs stops AddIn from loading RRS feed

  • Question

  • Hello

    Some information:

    I've added a Ribbon (XML) to my AddIn-project. I've opened the XML and added a command, and the file looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load">
      <commands>
        <command idMso="FileNew" onAction="ThisAddIn_FileNew"/>
      </commands>
      <ribbon>
      </ribbon>
    </customUI>

    The .cs file of the Ribbon.xml [Ribbon.cs] contains commented lines, that tells me to copy paste this function:

      protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
      {
          return new RibbonFileNew();
      }

    Into "ThisAddIn.cs", which I have done. 

    I've also created callback for the "ThisAddIn_FileNew" inside the "Ribbon.cs":

            /// <summary>
            /// This Function is called by the FileNewDocument.CS, that overrides the New button, within the Office Button [File > New]...
            /// </summary>
            public void ThisAddIn_FileNew(Office.Core.IRibbonControl control, ref bool Cancel)
            {
                ThisAddIn.ThisAddIn_FileNew(ref Cancel);
            }

    So the "Ribbon.XML" is loaded, but that stops my "Ribbon (Visual Designer)" from loading...

    How/Where do I register that the Ribbon.XML shown above also registers the Ribbon (Visual Designer) menu, which shows the AddIn in the main ribbon of word... Are you following? :)

     <commands>
        <command idMso="FileNew" onAction="ThisAddIn_FileNew"/>
      </commands>
      <ribbon>
        <tabs>
          <tab idMso="TabAddIns" id="RibbonMenu.cs" tag="Word AddIn" label="Helloworld" />
          <tab id="MyAddIn" tag="Word AddIn" insertAfterQ="true" insertAfterMso="true" getLabel="RibbonVisualDesigner.cs"></tab>
        </tabs>
      </ribbon>

    The above XML is "Ribbon.xml", I've tried various versions of the above... Where tag is the tag specified on "RibbonVisualDesigner.cs". PS: The above XML is wrong, but there must be something similar to register the Ribbon that is created as an item of type "Ribbon (Visual Designer)"?

    Bascially I got one Ribbon Visual Designer item and a Ribbon.XML item in the same Word 2007 AddIn, I want to run/show them both...

    I've also tried Right-Clicking in the RibbonVisualDesigner when viewing the Designer and chose "Export to XML", but nothing happens, no error, no new file, no, nothing... Visual studio 2010 Premium.

    Suggestions? 

    Edit: Oh lol! Right-clicking and chosing "Export to XML" in the RibbonVisualDesigner.cs [when viewing the designer], does create a XML file (or 13, at least I had 13 copies, due to clicking export to XML 13 times... :) ), but it created it at root of the project, not within the ~/Menus/Ribbons/<here> 

    Hm...


    • Edited by colaohye Friday, November 9, 2012 10:37 AM
    Friday, November 9, 2012 10:19 AM

Answers

  • Solved.

    Right-clicking the "RibbonVisualDesigner.cs" when viewing the designer, and chosing "Export to XML" gave me an XML file that I could manipulate, and I simply added the below to override FileNew button.

     <commands>
        <command idMso="FileNew" onAction="ThisAddIn_FileNew"/>
      </commands>

    And of course changed the "CreateRibbonExtensibilityObject()" to return the automatically created class based on the "RibbonVisualDesigner".



    • Marked as answer by colaohye Friday, November 9, 2012 10:36 AM
    Friday, November 9, 2012 10:36 AM

All replies

  • Solved.

    Right-clicking the "RibbonVisualDesigner.cs" when viewing the designer, and chosing "Export to XML" gave me an XML file that I could manipulate, and I simply added the below to override FileNew button.

     <commands>
        <command idMso="FileNew" onAction="ThisAddIn_FileNew"/>
      </commands>

    And of course changed the "CreateRibbonExtensibilityObject()" to return the automatically created class based on the "RibbonVisualDesigner".



    • Marked as answer by colaohye Friday, November 9, 2012 10:36 AM
    Friday, November 9, 2012 10:36 AM
  • Hi colaohve,

    I'm glad to hear you have solved your issue by yourself. Thanks for share you experience here, it really beneficial for other community members who have similar problem to see how your solved it.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, December 7, 2012 2:27 AM
    Moderator