Customised Ribbon using Custom UI editor for Microsoft Office

molesy01

Board Regular
Joined
Dec 23, 2012
Messages
61
Hi. I have created a new ribbon using the editor and have created about 60 new tabs. Well as you imagine having all these tabs are a bit of nightmare scrolling along to find the tab i want. Does anyone know if there is a way of using a macro to search for a particular tab, maybe a combobox?
thanks if you can help.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
You can use the ActivateTab method of the Ribbon object to activate the desired tab. So, for example, let's say that the variable MyRibbon represents the Ribbon object, and that the control ID for the desired tab is "customTab". The following will activate the tab...

Code:
MyRibbon.ActivateTab "customTab"

Hope this helps!
 
Upvote 0
Hi Domenic
Sorry dont quite understand. Ive tried that but it failed. where would i actually put the code?
thanks
 
Upvote 0
Here is an adaption of a code I wrote when I first installed Office 2016... Not sure if it will work with other office versions...This code is a vba alternative to using XML.

If the code works with your office version , it should list all your ribbon tabs on a userform listbox and you can activate the ribbon tabs by selecting their respective name from the listbox.

Here is a workbook example


Code goes on the UserForm:
Code:
Option Explicit

[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=If]#If[/URL]  VBA7 Then
    Private Declare PtrSafe Function AccessibleChildren Lib "oleacc" (ByVal paccContainer As Office.IAccessible, ByVal iChildStart As Long, ByVal cChildren As Long, ByRef rgvarChildren As Any, ByRef pcObtained As Long) As Long
[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=Else]#Else[/URL] 
    Private Declare Function AccessibleChildren Lib "oleacc" (ByVal paccContainer As Office.IAccessible, ByVal iChildStart As Long, ByVal cChildren As Long, ByRef rgvarChildren As Any, ByRef pcObtained As Long) As Long
[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=End]#End[/URL]  If

Private oCol As New Collection


Private Sub UserForm_Initialize()

    Const CHILDID_SELF = 0&
    Dim vElement As Variant, oIaccList() As IAccessible
    
    oIaccList = GetRibbonTabsList
    
    For vElement = 0 To UBound(oIaccList)
        Me.ListBox1.AddItem oIaccList(vElement).accName(CHILDID_SELF)
        oCol.Add oIaccList(vElement)
    Next

End Sub


Private Sub ListBox1_Change()

    Call oCol(ListBox1.ListIndex + 1).accDoDefaultAction(0&)

End Sub


Private Function GetRibbonTabsList() As Variant

    Const CHILDID_SELF = 0&
    Const NAVDIR_FIRSTCHILD = &H7
    Const NAVDIR_NEXT = &H5
    Const STATE_SYSTEM_INVISIBLE = &H8000&
    Dim oIacc As Office.IAccessible, oIaccFilteredArray() As Office.IAccessible
    Dim i As Long, k As Long    
    
    Set oIacc = Application.CommandBars("Ribbon")
    
    For i = 0 To 6
        Set oIacc = oIacc.accNavigate(NAVDIR_FIRSTCHILD, CHILDID_SELF)
    Next i
    
    For i = 0 To 7
        Set oIacc = oIacc.accNavigate(NAVDIR_NEXT, CHILDID_SELF)
    Next i
    
    Set oIacc = oIacc.accNavigate(NAVDIR_FIRSTCHILD, CHILDID_SELF)
    
    ReDim oIaccChildrenArray(oIacc.accChildCount - 1)
    
    Call AccessibleChildren(oIacc, 0, oIacc.accChildCount - 1, oIaccChildrenArray(0), 1)
    
    For i = LBound(oIaccChildrenArray) To UBound(oIaccChildrenArray) - 1
        If ((oIaccChildrenArray(i).accState(CHILDID_SELF) And (STATE_SYSTEM_INVISIBLE)) = 0) Then
            ReDim Preserve oIaccFilteredArray(k)
            Set oIaccFilteredArray(k) = oIaccChildrenArray(i)
            k = k + 1
        End If
    Next i
    
    GetRibbonTabsList = oIaccFilteredArray
    
End Function
 
Upvote 0
Hi Jaafar
Thank-you for your reply. Unfortunately i am not that good in excel to understand your code. I have created a custom ribbon using the editor and it has too many tabs so i cannot see the tabs on the end. All i would like to do is have a combo box on sheet1 so i can select the tab i require.
thanks
 
Upvote 0
Hi Domenic
Thank-you for your reply. Unfortunately i am not that good in excel to understand your code. I have created a custom ribbon using the editor and it has too many tabs so i cannot see the tabs on the end. All i would like to do is have a combo box on sheet1 so i can select the tab i require.
thanks
 
Upvote 0
Hi Jaafar
Thank-you for your reply. Unfortunately i am not that good in excel to understand your code. I have created a custom ribbon using the editor and it has too many tabs so i cannot see the tabs on the end. All i would like to do is have a combo box on sheet1 so i can select the tab i require.
thanks

Have you tried the workbook example in the link ?
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top