This example illustrates how to use a recursive function to enumerate all the UiControl objects that make up the Reflection Ribbon. It prints the id value of each UiControl object to the "immediate" pane in the Visual Basic editor.
Public Sub EnumerateUIControls() Dim controls() As UiControl Dim ctrlContainer As UiControlContainer Dim i As Long controls = ThisView.UiMode.SubItems For i = 0 To UBound(controls) Debug.Print controls(i).id Set ctrlContainer = controls(i) RecurseSubItems ctrlContainer.SubItems Next End Sub Private Sub RecurseSubItems(ctrls() As UiControl) Dim container As UiControlContainer Dim i As Long If UBound(ctrls) >= 0 Then For i = 0 To UBound(ctrls) Debug.Print ctrls(i).id On Error Resume Next Set container = ctrls(i) If Err = 0 Then RecurseSubItems container.SubItems Else Err.Clear End If Next End If End Sub