Consulting

Results 1 to 3 of 3

Thread: Ribbon customization issures

  1. #1
    VBAX Contributor
    Joined
    Jul 2017
    Location
    Zurich
    Posts
    132
    Location

    Ribbon customization issures

    Hi Folks

    Trying to customize the Menu Ribbon in Excel...such fun except that it isnt at all

    The idea is to have two states in the end...ie. to show all tabs..or to hide all tabs except for one customized tab

    Quite a bit of information was available at this site: https://www.rondebruin.nl/win/section2.htm

    but yet after many hours, i still can't figure it out
    Attached Files Attached Files
    Last edited by nikki333; 05-22-2018 at 03:10 PM.

  2. #2
    This seems to show all tabs:

    Sub subShowAllTabs()
        'Show every Tab, Group or Control(we use the wildgard "*")
        Call RefreshRibbon(Tag:="show")
    End Sub
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  3. #3
    VBAX Expert Logit's Avatar
    Joined
    Sep 2016
    Posts
    613
    Location
    .
    In the attached workbook from Ron's website, this macro hides all the tabs in the Menu Bar :

    'Note: in this example every macro above will show you the custom tab.
    'If you add more custom tabs this will be different
    
    
    Sub HideEveryTab()
    'Hide every Tab, Group or Control(we use Tag:="")
        Call RefreshRibbon(Tag:="")
    End Sub
    And these macros will make visible the HOME tab (CertainTag_1); the REVIEW tab (CertainTag_2); ALL TABS (CertainTab_3):

    Sub ShowTabGroupControlWithCertainTag_1()
    'Show only the custom Home tab with the Tag "ribhome"
        Call RefreshRibbon(Tag:="ribhome")
    End Sub
    
    
    Sub ShowTabGroupControlWithCertainTag_2()
    'Show only the custom Home tab with the Tag "ribreview"
        Call RefreshRibbon(Tag:="ribreview")
    End Sub
    
    
    Sub ShowTabGroupControlWithCertainTag_3()
    'Show every Tab, Group or Control(we use the wildgard "*")
    'You can also use "rib*" because all tags start with rib in this file
        Call RefreshRibbon(Tag:="*")
    End Sub
    You can use the first macro up top to hide all the tabs on the Menu Bar; then use one of the lower macro's as an example to show your custom tab. The only thing you'll need to change is this line :
    Call RefreshRibbon(Tag:="ribreview") .... editing the "ribreview" for the name of your tab. Presently it refers to the REVIEW tab.


    As Ron indicated in his code comments, make certain you include the following code at the top of the module first, then add your two macros for hiding all and showing just your custom tab.
    This code goes into the ROUTINE MODULE FIRST :

    Option Explicit
    
    
    Dim Rib As IRibbonUI
    Public MyTag As String
    
    
    'Callback for customUI.onLoad
    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 your workbook"
        Else
            Rib.Invalidate
        End If
    End Sub
    
    
    'Note: Do not change the code above
    
    
    
    
    '**********************************************************************************
    'Examples to show only the Tab you want with getVisible and tag in the RibbonX.
    '**********************************************************************************
    
    
    'In the example macro's below you I show you how to do it for the Home and Review tab
    'The tag's of the other tabs that you can use in the code are :
    
    
    'ribhome
    'ribinsert
    'ribpagelayout
    'ribformulas
    'ribdata
    'ribreview
    'ribview
    'ribdeveloper
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •