Editing a Legacy Custom Menubar in Access 2007<[email protected]>

K

Kevin Lyon

Hey Karen,

I have spent a lot of time trying to find examples to be able to edit a menubar from a previous version in Access 2007.

Finally, I have come up with the following that works! I hope this helps:

--- start code ---

Function TweakToolbar()
Dim cbr As CommandBar
Dim cbrctl As CommandBarControl
Dim cbrbutt As CommandBarButton
Dim ctl As Control
Dim prop As Property

' ****************************************
' *** Top menubar ?
' ****************************************
' For Each cbr In Application.CommandBars
' Debug.Print cbr.Index & ": " & cbr.Name
' Next

' ****************************************
' *** High-level menubar
' ****************************************
' For Each cbrctl In Application.CommandBars("Menus").Controls
' Debug.Print cbrctl.Index & ": " & cbrctl.Caption
' Next

' ****************************************
' *** This is where we are looking at the legacy menubar
' ****************************************
' For Each cbrctl In Application.CommandBars("Menus").Controls(1).Controls
' Debug.Print cbrctl.Index & ": " & cbrctl.Caption
' Next

' ****************************************
' *** Go really deep into the legacy menu
' ****************************************
' For Each cbrctl In Application.CommandBars("Menus").Controls(1).Controls(1).Controls(4).Controls
' Debug.Print cbrctl.Index & ": " & cbrctl.Caption
' Debug.Print cbrctl.OnAction
' Next

' ****************************************
' *** Get information on a item in the menubar
' ****************************************
' Set cbrctl = Application.CommandBars("Menus").Controls(1).Controls(2).Controls(11)
' Debug.Print cbrctl.Caption
' Debug.Print cbrctl.FaceId
' Debug.Print cbrctl.OnAction

' ****************************************
' *** Add an item to the menubar
' *** The OnAction uses a custom function we use to open Forms, Reports, etc.
' ****************************************
' Set cbrctl = Application.CommandBars("Menus").Controls(1).Controls(2)
' Set cbrbutt = cbrctl.Controls.Add
' With cbrbutt
' .Caption = "Journal Entry"
' .OnAction = "=OpenObject(2,""JournalEntry"",0,"""","""",1)"
' .FaceId = 1837
' End With

' ****************************************
' *** Remove an item from the menubar
' ****************************************
' Set cbrctl = Application.CommandBars("Menus").Controls(1).Controls(2).Controls(11)
' Debug.Print cbrctl.Caption
' cbrctl.Delete
End Function


--- end code ---


Good Luck!

Kevin

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top