Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Menu Controls Index

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
micklloyd - 25 Jan 2006 11:06 GMT
I have a custom menu bar ("DTSheet") with three popups each of whihc ha
a number of (sub)menu items. Each of the three menu bar popups has a
index which I can find using:

For Each cntrl In CommandBars("DTSheet").Controls
If cntrl.Visible = True Then MsgBox (cntrl.Index)
Next cntrl

However, this only finds the main menu bar controls, it does not fin
the (sub)menu item controls. I had hoped to beat it by using th
following:

For Each cntrl In CommandBars("DTSheet").Controls(1)
If cntrl.Visible = True Then MsgBox (cntrl.Index)
Next cntrl

to find the controls in each menu bar popup in turn. But this return
an "Object does not support this proprty or method" error.

Any help much appreciated

Mic
RB Smissaert - 25 Jan 2006 11:28 GMT
I think a For Each loop will work.
This is a code fragment I have for a popup menubar in a userform, but I
think it will work in your situation:

   Dim oCBButton1 As CommandBarControl
   Dim oCBButton2 As CommandBarControl
   Dim oCBButton3 As CommandBarControl
   Dim lButtonCount As Long

   For Each oCBButton1 In cb2.Controls
       'top level buttons
       '-----------------
       If oCBButton1.Type = msoControlButton Then
           lButtonCount = lButtonCount + 1
       Else    'If oCBButton1.Type = msoControlButton
           For Each oCBButton2 In oCBButton1.Controls
               'second level buttons
               '--------------------
               If oCBButton2.Type = msoControlButton Then
                   lButtonCount = lButtonCount + 1
               Else
                   For Each oCBButton3 In oCBButton2.Controls
                       'third level buttons
                       '-------------------
                       If oCBButton3.Type = msoControlButton Then
                           lButtonCount = lButtonCount + 1
                       End If
                   Next    'For Each oCBButton3 In oCBButton2.Controls
               End If    'If oCBButton2.Type = msoControlButton
           Next    'For Each oCBButton2 In oCBButton1.Controls
       End If    'If oCBButton1.Type = msoControlButton
   Next  'For Each oCBButton1 In cb2.Controls

RBS

> I have a custom menu bar ("DTSheet") with three popups each of whihc has
> a number of (sub)menu items. Each of the three menu bar popups has an
[quoted text clipped - 18 lines]
>
> Mick
micklloyd - 26 Jan 2006 05:34 GMT
Thanks RBS

Enough here to enable me to get what I want

Signature

micklloyd

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.