PDA

View Full Version : [SOLVED:] Ribbon customization issures



nikki333
05-22-2018, 12:57 PM
Hi Folks

Trying to customize the Menu Ribbon in Excel...such fun :D 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 :(

Jan Karel Pieterse
05-23-2018, 08:07 AM
This seems to show all tabs:


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

Logit
05-23-2018, 08:55 AM
.
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