Finding Visible Controls with FindControls
Sub FindVisibleControls()
Dim ctrls As CommandBarControls
Dim ctrl As CommandBarControl
Set ctrls = Application.CommandBars.FindControls(, , , True)
For Each ctrl In ctrls
Debug.Print ctrl.Parent.name
Debug.Print ctrl.Caption
Debug.Print ctrl.Index
Debug.Print ctrl.ID
Debug.Print ctrl.Enabled
Debug.Print ctrl.Visible
Debug.Print ctrl.IsPriorityDropped
Debug.Print TranslateControlType(ctrl.Type)
Next
Set ctrl = Nothing
Set ctrls = Nothing
End Sub
Function TranslateControlType(vType As MsoControlType) As String
Dim sType As String
Select Case vType
Case Is = MsoControlType.msoControlActiveX
sType = "ActiveX"
Case Is = MsoControlType.msoControlAutoCompleteCombo
sType = "Auto Complete Combo"
Case Is = MsoControlType.msoControlButton
sType = "Button"
Case Is = MsoControlType.msoControlButtonDropdown
sType = "Button Dropdown"
Case Is = MsoControlType.msoControlButtonPopup
sType = "Button Popup"
Case Is = MsoControlType.msoControlComboBox
sType = "Combo Box"
Case Is = MsoControlType.msoControlCustom
sType = "Custom"
Case Is = MsoControlType.msoControlDropdown
sType = "Dropdown"
Case Is = MsoControlType.msoControlEdit
sType = "Edit"
Case Is = MsoControlType.msoControlExpandingGrid
sType = "Expanding Grid"
Case Is = MsoControlType.msoControlGauge
sType = "Gauge"
Case Is = MsoControlType.msoControlGenericDropdown
sType = "Generic Dropdown"
Case Is = MsoControlType.msoControlGraphicCombo
sType = "Graphic Combo"
Case Is = MsoControlType.msoControlGraphicDropdown
sType = "Graphic Dropdown"
Case Is = MsoControlType.msoControlGraphicPopup
sType = "Graphic Popup"
Case Is = MsoControlType.msoControlGrid
sType = "Grid"
Case Is = MsoControlType.msoControlLabel
sType = "Label"
Case Is = MsoControlType.msoControlLabelEx
sType = "Label Ex"
Case Is = MsoControlType.msoControlOCXDropdown
sType = "OCX Dropdown"
Case Is = MsoControlType.msoControlPane
sType = "Pane"
Case Is = MsoControlType.msoControlPopup
sType = "Popup"
Case Is = MsoControlType.msoControlSpinner
sType = "Spinner"
Case Is = MsoControlType.msoControlSplitButtonMRUPopup
sType = "Split Button MRU Popup"
Case Is = MsoControlType.msoControlSplitButtonPopup
sType = "Split Button Popup"
Case Is = MsoControlType.msoControlSplitDropdown
sType = "Split Dropdown"
Case Is = MsoControlType.msoControlSplitExpandingGrid
sType = "Split Expanding Grid"
Case Is = MsoControlType.msoControlWorkPane
sType = "Work Pane"
Case Else
sType = "Unknown control type"
End Select
TranslateControlType = sType
End Function
Related examples in the same category