[AccessD] CommandBarControl subitems

Susan Harkins harkins at iglou.com
Mon Apr 7 15:39:27 CDT 2003


Well, I don't think it does what I'm after. Your code seems to refer to the command bar and its controls -- I'm looking for the controls' controls. For instance: 

Menu bar: File: New, Open, SaveAs..., 

I'm trying to loop through New, Open, Save As, and so on. 

Susan H. 



  Susan, 

  Here is some code that might help.  You will need to modify it as I just took it out of one of my programs that calls it to hide ALL command bars, etc. 

  I hope this helps. 


  Sub hideCommandBars() 
      Dim cbr As CommandBar 
      For Each cbr In CommandBars 
          hidebar cbr 
      Next cbr 
  End Sub 
  Sub listbar(level As Integer, thisbar As CommandBar) 
      Dim cbrctl As CommandBarControl 
      Dim indent As Integer 
      ' Indent the command bar depending on its level in 
      ' the menu structure. 
      For indent = 1 To level 
          MsgBox "   " 
      Next indent 
      Select Case thisbar.Type 
          Case msoBarTypeMenuBar 
              MsgBox "Menu Bar: " & thisbar.name 
          Case msoBarTypeNormal 
              MsgBox "Toolbar: " & thisbar.name 
          Case msoBarTypePopup 
              MsgBox "Popup: " & thisbar.name 
      End Select 
      For Each cbrctl In thisbar.Controls 
      ' If the control doesn't have a command bar associated 
      ' with it, then don't print it. 
          If cbrctl.Type <> 1 And cbrctl.Type <> 2 _ 
                And cbrctl.Type <> 4 And cbrctl.Type <> 16 _ 
                And cbrctl.Type <> 18 Then 
              listbar level + 1, cbrctl.CommandBar 
          End If 
      Next cbrctl 
  End Sub 
  Sub hidebar(thisbar As CommandBar) 
      Dim cbrctl As CommandBarControl 
      Dim indent As Integer 
      ' Indent the command bar depending on its level in 
      ' the menu structure. 
      For indent = 1 To level 
          MsgBox "   " 
      Next indent 
      Select Case thisbar.Type 
          Case msoBarTypeMenuBar 
              DoCmd.ShowToolbar thisbar.name, acToolbarNo 
          Case msoBarTypeNormal 
              DoCmd.ShowToolbar thisbar.name, acToolbarNo 
          Case msoBarTypePopup 
              DoCmd.ShowToolbar thisbar.name, acToolbarNo 
      End Select 
      For Each cbrctl In thisbar.Controls 
      ' If the control doesn't have a command bar associated 
      ' with it, then don't print it. 
          If cbrctl.Type <> 1 And cbrctl.Type <> 2 _ 
                And cbrctl.Type <> 4 And cbrctl.Type <> 16 _ 
                And cbrctl.Type <> 18 Then 
              listbar level + 1, cbrctl.CommandBar 
          End If 
      Next cbrctl 
  End Sub 


       "Susan Harkins" <harkins at iglou.com> 
        Sent by: accessd-bounces at databaseadvisors.com 
        04/07/2003 02:47 PM 
        Please respond to accessd 

               
                To:        AccessD at databaseadvisors.com 
                cc:         
                Subject:        [AccessD] CommandBarControl subitems 



  If a CommandBarControl on a menu bar contains submenus, how do I cycle
  through that control's collection to list the submenus? This is driving me
  nuts -- I can't figure out how to reference a control's Collection -- does a
  control have a collection? I'm assuming it does if there are submenus?????


  Dim cbarMenu As CommandBar
   Dim cbarControl As CommandBarControl
   Dim cbarSub As CommandBarControl
   'Dim cbarcolControls As CommandBarControls
   Set cbarMenu = CommandBars(barname)
   For Each cbarControl In cbarMenu.Controls
     If cbarControl.Id = controlname Then
       For Each control in cbarControl's collection...


  This is where I get lost -- at this point, I need to declare cbarControl's
  collection, and I can't get it.


  Susan H.

  _______________________________________________
  AccessD mailing list
  AccessD at databaseadvisors.com
  http://databaseadvisors.com/mailman/listinfo/accessd
  Website: http://www.databaseadvisors.com






------------------------------------------------------------------------------


  _______________________________________________
  AccessD mailing list
  AccessD at databaseadvisors.com
  http://databaseadvisors.com/mailman/listinfo/accessd
  Website: http://www.databaseadvisors.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030407/078c3eea/attachment-0001.html>


More information about the AccessD mailing list