Function SetMenus(DefMenuState As Boolean, AppMenuState As Boolean)
Dim cbc As CommandBarControl
On Error GoTo errHandler
'*******************
'AppMenuState (for the application) and DefMenuState (for default)are the variables being
'passed to show/hide a menu bar. 'This is called on startup and shutdown. Defaults are
're-established on shutdown, custom program menu is established on startup
'*******************
CommandBars("Menu Bar").Enabled = DefMenuState
CommandBars("Database").Enabled = DefMenuState
CommandBars("mnuMain").Visible = AppMenuState
exitHere:
Exit Function
errHandler:
Call errMsg
Resume exitHere
End Function
Public Function DisableMenu(UserLevel As String)
Dim cb As CommandBar
Dim cbpAdmin As CommandBarPopup
On Error GoTo errHandler
Set cb = CommandBars!mnuMain
'*************
'the following prints menu items in immediate window to check their names
'Debug.Print cb.Controls.Item("&Admin").Caption
'Debug.Print cb.Controls.Item("&Admin").CommandBar.Controls(3).Caption
'*************
'using function & cases permits different combinations for any level that may be added
Now I'm not sure if you're referring to a VB5/6 from 2003 (Visual Basic) app, which would be kind of outdated, or Access. Partly also because I don't recall being able to manipulate tool or menu bars via any design view property box. It was usually Access Options dialogs that allowed you to show/hide menu bars, but that predates the Office ribbon. So if your project really is VB (i.e. VB5, VB6 or VB.Net) the code I posted will be useless to you. Good luck with your project.The VBA app. I am working on restricts my option for customization.