Hide all Access Toolbars and Menubars

ghudson

Registered User.
Local time
Today, 17:17
Joined
Jun 8, 2002
Messages
6,194
The below code will hide ALL menu bars and ALL tool bars. Ensure that you have a way to unhide the menu bars and tool bars before you hide them! You should place the hide all tool bars routine in your opening splash screen form for it only needs to be run once when the db is first opened.

This will hide all menu bars and tool bars
Dim i As Integer
For i = 1 To CommandBars.Count
CommandBars(i).Enabled = False
Next i

This will unhide all menu bars and tool bars
Dim i As Integer
For i = 1 To CommandBars.Count
CommandBars(i).Enabled = True
Next i

An added bonus is the right-click mouse button option is disabled if the menu bars are disabled with the above code.

Use the 'ShowToolbar' command if you need to display a tool bar or menu bar...
DoCmd.ShowToolbar "YourToolBarNameHere", acToolbarYes

This will hide a tool bar or menu bar when needed...
DoCmd.ShowToolbar "YourToolBarNameHere", acToolbarNo

This will hide the menu bar...
DoCmd.ShowToolbar "Menu Bar", acToolbarNo

You can also hide/unhide the database window with code...

Hide the database window
DoCmd.SelectObject acTable, , True
DoCmd.RunCommand acCmdWindowHide

Unhide the database window
DoCmd.SelectObject acTable, , True

Remove the "Type a question for help" on the default menu bar in Access 2002 or 2003
Application.CommandBars.DisableAskAQuestionDropdown = True

This command will prevent the db from opening up a separate window tab on the Taskbar
Application.SetOption "ShowWindowsinTaskbar", False

The above commands have been successfully tested with Access 97 and Access 2003.

Read this if you do not understand where to post your questions! >>> Please Read Before Posting (http://www.access-programmers.co.uk/forums/showthread.php?t=63576)

Please do not directly PM me with any questions related to my Hide all Access Toolbars and Menubars code. Please do not post any questions related to my Hide all Access Toolbars and Menubars code in the Code Repository forum. If you have a question related to the Hide all Access Toolbars and Menubars code... Please post your questions in the appropriate forum and include a link to this thread if you have a question or problem related to my Hide all Access Toolbars and Menubars code. I will be glad to help if I see your post and if I am available.

Key words: toolbars, tool bars, menubar, menu bars, hide, unhide, enable, disable, right click, right-click, database window, hide database window,
 
This will hide all menu bars and tool bars
Dim i As Integer
For i = 1 To CommandBars.Count
CommandBars(i).Enabled = False
Next i

Use the 'ShowToolbar' command if you need to display a tool bar or menu bar...
DoCmd.ShowToolbar "YourToolBarNameHere", acToolbarYes

If I load the first bit of code in my splash screen for and then place the docmd.showtoolbar line in the onload event in my report should that not turn on my toolbar. My toolbar is called Print and the line i use is ...

DoCmd.ShowToolbar "Print", acToolbarYes

It did not turn on the toolbar
 
In 2007 I use the USysRibbon table to control the Ribbon.

Hide almost everything in the ribbon. Only Close is left. In the Access Options, Current Database use MyHide as the ribbon name.
Code:
MyHide
 
<customUI xmlns="[URL]http://schemas.microsoft.com/office/2006/01/customui[/URL]">
<ribbon startFromScratch="true">
   <officeMenu>
        <button idMso="FileOpenDatabase" visible="false" />
         <button idMso="FileNewDatabase" visible="false" />
         <splitButton idMso="FileSaveAsMenuAccess" visible="false" />
     </officeMenu>
</ribbon>
</customUI>

Show the print options when opening a report. In report options use MyReport as the ribbon name.
Code:
MyReport
 
<customUI xmlns="[URL]http://schemas.microsoft.com/office/2006/01/customui[/URL]">
<ribbon startFromScratch="true">
<tabs>
<tab id="MyReport" label="Report">
<group idMso="GroupPrintPreviewPrintAccess" />
<group idMso="GroupPageLayoutAccess" />
<group idMso="GroupZoom" />
<group idMso="GroupPrintPreviewClosePreview" />
</tab>
</tabs>
</ribbon>
</customUI>
 
I don't see the USysRibbon table in my NavPane even when hidden objects and system objects are selected under Access Options. What gives?

I'm using Access 2007
 

Users who are viewing this thread

Back
Top Bottom