Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Easy count of custom menuitems that perform an action (macro)

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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to perform action based on value in cell jackie Excel Programming 1 June 21st 07 07:39 PM
Need to perform action on range Mike G.[_3_] Excel Programming 3 March 3rd 07 10:29 PM
Add menuitems to custom created menu René[_2_] Excel Programming 1 January 22nd 06 02:34 PM
How to 'Click and then perform action' chris100[_7_] Excel Programming 14 August 2nd 05 02:57 PM
How to perform action in all worksheets Sethaholic Excel Programming 6 July 11th 05 07:44 PM


All times are GMT +1. The time now is 03:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"