Hi Andy,
No problem on the multipost - sometimes it happens by accident, more often
it happens when someone is unfamiliar with the newsgroups. Not having a
working crystal ball handy <g>, I generally just go ahead and post the link
and the standard instructions on crossposting vs multiposting.
Yes, the version of Access is relevant in this questioin - only because my
sample is only for A2000 and above. I'll convert it to A97 and get someone
to try it out. If all goes well, I'll put it on my website.
Basically you enumerate the commandbars collection, then with each
commandbar you enumerate the commandbar.controls collection. Here's the
tricky part, for each commandbar control if the type is msoControlPopup you
must also enumerate its controls collection. In my code, this is done
recursively. Here is some cut-down code to get you started. I think it will
work in A97 but it has been so long since I've actually used A97 that I
honestly don't know for sure!
Sub listCommandBars()
Dim cb As CommandBar
Dim lngCBId As Long
For Each cb In CommandBars
'take out this test if you want ALL commandbars
If cb.BuiltIn = False Then
Debug.Print "****************"
Debug.Print "* CommandBar *"
Debug.Print cb.Name, cb.Position
listCBControls cb.Name
Debug.Print "* CommandBar *"
Debug.Print "****************"
endif
Next cb
set cb=nothing
End Sub
Public Sub listCBControls(pstrCBName As String)
Dim cbi As CommandBarControl
Dim lngCBItemid As Long
Dim lngGroup As Long
Dim lngSort As Long
lngGroup = 1
lngSort = 1
For Each cbi In CommandBars(pstrCBName).Controls
Debug.Print cbi.Caption, cbi.Type, cbi.Index, cbi.Id, cbi.Tag
If cbi.Type = msoControlPopup Then
listCBMenuItems cbi
End If
Next cbi
set cbi=nothing
End Sub
Sub listCBMenuItems(pCbiMenu As CommandBarControl)
Dim cbi As CommandBarControl
Dim lngCBItemid As Long
Dim lngGroup As Long
Dim lngSort As Long
lngGroup = 1
lngSort = 1
Debug.Print "****************"
Debug.Print "* Sub Menu *"
For Each cbi In pCbiMenu.Controls
Debug.Print cbi.Caption, cbi.Type, cbi.Index, cbi.Id, cbi.Tag
If cbi.Type = msoControlPopup Then
listCBMenuItems cbi
End If
Next cbi
Debug.Print "* End Sub Menu *"
Debug.Print "****************"
set cbi=nothing
End Sub