View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default VB - Macro to list all controls in the Commandbar.

Hi,

Try this

Sub MenuOptions()
Dim ctrl As CommandBarControl
Dim MenOption As CommandBarControl
Dim rw As Long
rw = 2
For Each ctrl In Application.CommandBars("Worksheet Menu Bar").Controls
Sheets("Command Bars").Cells(rw, "B") = _
WorksheetFunction.Substitute(ctrl.Caption, "&", "")
rw = rw + 1
For Each MenOption In ctrl.Controls
Cells(rw, "B").HorizontalAlignment = xlRight
Sheets("Command Bars").Cells(rw, "B") = _
WorksheetFunction.Substitute(MenOption.Caption, "&", "")
rw = rw + 1
Next
Next ctrl
End Sub

Mike

"LABKHAND" wrote:

Hi All,

Through VB code, I have added a new custom menu to the Commandbar("Worksheet
Menu Bar"). This custom menu has several controls (menus/submenus). I am
trying to write a VB macro that gets me name of each control (menu/submenus)
in this custom menu item. Any help would be appreciated.

Thx


I am trying to write a vb code to list name of all Excel commandbars and
their associated controls (menus/submenus). For example I have created a
custom menu in Excel with several sub-menus in it. I need to get name of
each control in this custom menu item in the "WorkSheet Menu Bar".