none
how to hide standard button in ribbon ? RRS feed

  • Question

  • hello everybody,

    I implement a software prototype for show if my idea is possible.

    I would like to create a custom ribbon : 

    add custom tab, group, button... is OK

    hide standard group (tabHome...) is OK

    I would like to hide a standard button or control, such as Format painter Control (idMso is FormatPainter in GroupClipboard group, in TabHome tab or Cut button (idMso is Cut) in the same parent.

    I am trying with visible="false", such as for group and tab, but the button is always visible. visible="false" work with parent components (tab and group)

    My XML code : 

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
      <ribbon
        startFromScratch="true">
        <tabs>
          <tab idMso="TabHome" visible="true">
               <group idMso="GroupClipboard" visible="true" >
                <control idMso="Cut" visible="false" />
                 <button idMso="FormatPainter" visible="false" />
               </group>
            <group idMso="GroupStyles" visible="false"/>
            <group idMso="GroupParagraph">
              <gallery idMso="LineSpacingGallery" visible="false"/>
            </group>
          </tab>
          <tab idMso="TabView" visible="true" />
          <tab idMso="TabInsert" visible="true" />
          <tab id="Designer1" label="Designer">
            <group id="Group1" label="Composants">
              <menu id="menu1" label="Insertion">
                <button id="bouton1" label="Texte" />
                <button id="bouton2" label="Image" />
              </menu>
            </group>
          </tab>
          
          <tab
            id="rxTab0"
            label="Onglet (tab) exemple 1">
            <group
        id=      "rxGrp0"
        label    ="Groupe 1 onglet exemple 1">
              <toggleButton
                     id="rxtglBtn0" label="Sourire"
                     imageMso="HappyFace"
                     size="normal" />
            </group>
            <group
        id="rxGrp1"
        label="Groupe 1 onglet exemple 1">
              <button label="label bouton" id="bouton11" visible="true"/>
            </group>
          </tab>
          <tab
            id="rxTab1"
            label="Menu (tab) exemple 2" >
            <group           id="rxGrp21"
    
              label="Groupe 1 onlet exemple 2">
              <button label="label bouton DE GROUPE 1 EXEMPLE 2" visible="true" id="bouton21" imageMso="HappyFace" size="large"/>
              
            </group>
          </tab>
        </tabs>
      </ribbon>
    </customUI>
    


    I search with Forums and I don't found this info : why visible="false" don't work with button or  other object such as gallery...

    My code is in ribbon1.xml in office addin application build with Visual Studio 2013 for Word 2013.

    Please, help me for resolve my problem.

    Thnak you for your help.


    Thursday, September 11, 2014 1:02 PM

Answers

  • Hi Christophe,

    If you took a look at the articles you might noticed the following:

    "It is not possible to override these commands from the custom UI XML markup or by using the object model... A better solution would be to consider hiding the built-in UI and rebuilding it fully with custom commands."

    So, if you want to hide a built-in control you need to use the startFromScratch mode (see the corresponding property in the ribbon markup) and rebuild the entire ribbon from the ground excluding the required controls.

    Be aware, you can add built-in controls to your own tab where you can disable or hide them at runtime.


    Friday, September 12, 2014 12:21 PM
  • Hi Christophe

    It's not possible to change the contents of a built-in Group in the Ribbon. It's not necessary to go the full start-from-scratch route, as Eugene suggests. But you would need to create a custom Group to replace the built-in group. Sometimes, it's not possible to create a Group that looks exactly the same since not all the controls and positioning available to Microsoft is also exposed to the developer. But you should be able to use the msoId to include all the same controls as the built-in group contains (and you want to use).


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, September 12, 2014 6:25 PM
    Moderator

All replies

  • Hello Christopher,

    What button exactly do you want to hide? Is it located inside the menu tag?

    Note, you can try to use callbacks instead, for example, replace the visible="false" attribute with the getVisible="YourCallbackSub" one. It allows to hide ribbon controls dynamically. Don't forget to define the callback in the code behind file (your C# or VB.NET files). 

    The Fluent UI (aka Ribbon UI) is described in depth in the following series of articles:

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

    Thursday, September 11, 2014 1:57 PM
  • Hello Eugene

    thank you for your response.

    I know serie of articles described the Fluent UI.

    I want to hide for exemple "Cut" button and "Format Painter" button (standard button in in GroupClipboard group, in TabHome tab)

    the article confirm that button have a propertie "visible". but this propertie don't work in my code.

    I use also callback method for test get visible but it dont' work also

    I don't understand because it's a basic propertie...

    I use WordControls.xlsx (Microsoft publication for entire idMso Word) for find "idMso" for the use of standard button, group,...

    do you have a suggestion, according to my XML code ?

    thank you for your help

    regards


    Thursday, September 11, 2014 2:19 PM
  • Hi Christophe,

    If you took a look at the articles you might noticed the following:

    "It is not possible to override these commands from the custom UI XML markup or by using the object model... A better solution would be to consider hiding the built-in UI and rebuilding it fully with custom commands."

    So, if you want to hide a built-in control you need to use the startFromScratch mode (see the corresponding property in the ribbon markup) and rebuild the entire ribbon from the ground excluding the required controls.

    Be aware, you can add built-in controls to your own tab where you can disable or hide them at runtime.


    Friday, September 12, 2014 12:21 PM
  • Hi Christophe

    It's not possible to change the contents of a built-in Group in the Ribbon. It's not necessary to go the full start-from-scratch route, as Eugene suggests. But you would need to create a custom Group to replace the built-in group. Sometimes, it's not possible to create a Group that looks exactly the same since not all the controls and positioning available to Microsoft is also exposed to the developer. But you should be able to use the msoId to include all the same controls as the built-in group contains (and you want to use).


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, September 12, 2014 6:25 PM
    Moderator