R
Robert Avery
In case anyone else would like to find out how many custom menuitems
they have made...
Sub CountAllCustomMacrosInExcel()
Dim cb As Office.CommandBar
Dim CBC As Office.CommandBarControl
Dim count As Long
For Each cb In Application.CommandBars
For Each CBC In cb.Controls
RecursiveCountMacroButtons CBC, count
Next
Next
Debug.Print count
End Sub
Public Function RecursiveCountMacroButtons(CBC As
Office.CommandBarControl, ByRef count As Long)
Dim cbp As Office.CommandBarPopup
Dim cbb As Office.CommandBarButton
Dim ncbc As Office.CommandBarControl
If TypeOf CBC Is Office.CommandBarPopup Then
Set cbp = CBC
For Each ncbc In cbp.Controls
RecursiveCountMacroButtons ncbc, count
Next
ElseIf TypeOf CBC Is Office.CommandBarButton Then
Set cbb = CBC
If Not cbb.BuiltIn Then
If Len(cbb.OnAction) Then
count = count + 1
'Cells(count + 2, 1) = cbb.OnAction
End If
End If
End If
End Function
they have made...
Sub CountAllCustomMacrosInExcel()
Dim cb As Office.CommandBar
Dim CBC As Office.CommandBarControl
Dim count As Long
For Each cb In Application.CommandBars
For Each CBC In cb.Controls
RecursiveCountMacroButtons CBC, count
Next
Next
Debug.Print count
End Sub
Public Function RecursiveCountMacroButtons(CBC As
Office.CommandBarControl, ByRef count As Long)
Dim cbp As Office.CommandBarPopup
Dim cbb As Office.CommandBarButton
Dim ncbc As Office.CommandBarControl
If TypeOf CBC Is Office.CommandBarPopup Then
Set cbp = CBC
For Each ncbc In cbp.Controls
RecursiveCountMacroButtons ncbc, count
Next
ElseIf TypeOf CBC Is Office.CommandBarButton Then
Set cbb = CBC
If Not cbb.BuiltIn Then
If Len(cbb.OnAction) Then
count = count + 1
'Cells(count + 2, 1) = cbb.OnAction
End If
End If
End If
End Function