none
Custom Ribbon not showing when .dotm is loaded from StartUp folder RRS feed

  • Question

  • Hi,

    I hope you can help me with this.

    I created a .dotm file with a custom tab in de ribbon. When I open this template, the custom tab is there. But when I move the template to the startup folder and then start Word, the custom tab is not there.

    What can I do to solve this.

    the XML:

    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" >
      <ribbon>
        <tabs>
          <tab id="SST" label="S Stationary Templates" insertBeforeMso="TabHome" getVisible="GetVisible" tag="Report">
            
    	  <group id="Data" label="Data" >
    	    <button id="Button1" label="Edit Personal Data" image="EditPersonalData" supertip="Change Personal Data in form" screentip="Data Form"
               size="large" onAction="ShowPersonalData" />
     	  </group>
    
    	 <group id="New" label="Create New" >
    	    <button id="Button2" label="New Letter" image="NewLetter" supertip="Create New Letter" screentip="New Letter"
               size="large" onAction="NewLetter" />
     	  </group>
    	 
    
          </tab>
        </tabs>
      </ribbon>
    </customUI>
    

    Saturday, February 14, 2015 6:24 PM

Answers

  • Hi Mon'que

    OK... I think you're missing some of the pieces.

    1. The VBA code you show has a RibbonOnLoad sub. This won't execute because you don't have a callback to it in the customUI element of your XML: onLoad="RibbonOnLoad"

    2. There's nothing in the code or XML you show that triggers DisplayRibbonTab, so RefreshRibbon is never called. As a result, the variable MyTag is never populated. Since GetVisible checks the value of MyTag and, it being an empty string, it cannot match any of the test values, GetVisible returns "false", thus the tag will not display.

    3. Even if DisplayRibbonTab were being called, the Tag in your XML is "Report", not SST or show, the two values being checked in GetVisible. So, again, the Tab won't show.

    So, if you remove the getVisible="GetVisible" from your XML code I would expect the tab to display?


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by L.HlModerator Tuesday, February 24, 2015 5:19 AM
    Saturday, February 14, 2015 8:45 PM
    Moderator

All replies

  • Hi,

    Do you open the template? The ribbon will not show when you just open Word. Unless you added your ribbon to the normal dot file.

    Maurice


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer. Thank You

    Saturday, February 14, 2015 6:56 PM
  • Hi Mon'que

    What you describe you want to do should definitely work. I performed a quick test here using Word 2010 and can confirm it does work.

    Perhaps you're not saving the template to the correct folder? Theoretically, this can be any folder on the system, but the installation default is reasonable predictable, although it depends on the versions of Word and Windows. For more information, see, for example http://www.addbalance.com/word/startup.htm


    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, February 14, 2015 7:24 PM
    Moderator
  • I saved the file with the ribbon in the Startup folder. So it is loaded as a global template.
    It is listed in the Templates and Addins dialogbox.

    Saturday, February 14, 2015 7:27 PM
  • Hi Cindy,

    Thanks for your reply. I'm using Word 2010 as well, for this project. I created a Startup folder om my harddrive and stored my template there. In Word 2010 I changed the file location for Startup to be my new folder. And when I start Word 2010 again, the template is loaded as global. But my custom tab is not there?

    When I open the file in Word, then the custum tab is where it should be, but I need this tab to show automatically.

    Saturday, February 14, 2015 7:38 PM
  • Hi Mon'que

    Mmm. My first thought is that the Ribbon XML is causing errors and your system may not be configured to show them (File/Options/Advanced/General/Show Add-in user interface errors). But if that were the case, then you'd be seeing these when you open the template directly...?

    FWIW I copied your Ribbon XML when I performed my test. I had to remove the onAction and image information since I don't have the macros or the images (and didn't want to take the time to do anything about it). Of course, before I'd removed those things I was getting errors and the tab did not display. But once I took care of the errors the tab appeared (and is still there since I haven't removed the template from my Startup folder).

    I can't think of anything, off-hand, that could prevent the tab from loading except Safe Mode, but perhaps something is interfering. Do you have any third-party Add-ins installed?


    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, February 14, 2015 8:00 PM
    Moderator
  • Hi Cindy,

    Thank you for all your efforts. I have Acrobat installed. I disabled the add-in, but didn't help.

    I have the following code in my template, which I found on the web: If I leave that out, I get Twice:
    "The macro cannot be found or has been disabled because of your Macro security settings."

    Dim Rib As IRibbonUI
    Public MyTag As String
    
    Sub RibbonOnLoad(ribbon As IRibbonUI)
        Set Rib = ribbon
    End Sub
    
    Sub GetVisible(control As IRibbonControl, ByRef visible)
        If MyTag = "show" Then
            visible = True
        Else
            If control.Tag Like MyTag Then
                visible = True
            Else
                visible = False
            End If
        End If
    End Sub
    
    Sub RefreshRibbon(Tag As String)
        MyTag = Tag
    
        If Rib Is Nothing Then
            MsgBox "Error, Save/Restart Word"
        Else
            Rib.Invalidate
        End If
    End Sub
    
    Sub DisplayRibbonTab()
        Call RefreshRibbon(Tag:="SST")
    End Sub
    

    Saturday, February 14, 2015 8:26 PM
  • Hi Mon'que

    OK... I think you're missing some of the pieces.

    1. The VBA code you show has a RibbonOnLoad sub. This won't execute because you don't have a callback to it in the customUI element of your XML: onLoad="RibbonOnLoad"

    2. There's nothing in the code or XML you show that triggers DisplayRibbonTab, so RefreshRibbon is never called. As a result, the variable MyTag is never populated. Since GetVisible checks the value of MyTag and, it being an empty string, it cannot match any of the test values, GetVisible returns "false", thus the tag will not display.

    3. Even if DisplayRibbonTab were being called, the Tag in your XML is "Report", not SST or show, the two values being checked in GetVisible. So, again, the Tab won't show.

    So, if you remove the getVisible="GetVisible" from your XML code I would expect the tab to display?


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by L.HlModerator Tuesday, February 24, 2015 5:19 AM
    Saturday, February 14, 2015 8:45 PM
    Moderator
  • Thank you! That solved it. Now my tab is showing in the ribbon, when I start Word.

    In the mean time I found a dirty way to solve my issue, by adding this macro to my template:

    Sub AutoExec()
        MyTag = "show"
    End Sub

    But of course your instruction is much better.

    Saturday, February 14, 2015 8:52 PM