Connecting Tech Pros Worldwide Help | Site Map

CommandBars in Access 2002/2003

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 13th, 2005, 12:41 PM
deko
Guest
 
Posts: n/a
Default CommandBars in Access 2002/2003

I'm trying to prevent any built-in command bars or menu bars from appearing
in an Access MDE.

I have the following code on the Form_Open event of the app's main form:

CommandBars("Menu Bar").Enabled = False

This works, but if a user has been using Access with a tool bar visible
(Form/Report
Formatting, for example) prior to opening my MDE, that tool bar is still
visible when my MDE is opened - despite not having a Menu Bar.

Can I just loop through the entire collection of command bars and disable
them all?

'Required reference Office 11.0 Object Library
Dim cb As CommandBar
For Each cb In CommandBars
cb.Enabled = False
Next

There are 177 named CommandBars in this loop, however. If I go to Tools >
Customize, I see only 28 Toolbars (on the Toolbars tab of the Customize
dialog).

Which toolbars can I safely disable? The only ones I really need to hide
are the ones that may still be visible after the app's main form is
maximized and the Menu Bar is disabled (since toolbars cannot be made
visible if there is no Menu Bar and the main form is maximized). The stuff
available on right click I can deal with elsewhere.

Other suggestions?

Thanks in advance.



  #2  
Old November 13th, 2005, 12:42 PM
deko
Guest
 
Posts: n/a
Default Re: CommandBars in Access 2002/2003

By trial and error, this list seems to be exhaustive.

Whatever other toolbars there are, they cannot be made visible once this
code is run.

Private Sub Form_Open(Cancel As Integer)
Dim varCb As Variant
'On Error Resume Next
For Each varCb In Array( _
"Task Pane", "Database", "Menu Bar", "Report Design", _
"Page View", "Alignment and Sizing", "Formatting (Page)", _
"Formatting (Datasheet)", "Print Preview", "Form Design", _
"Toolbox", "Form View", "Formatting (Form" & Chr(47) & "Report)", _
"Source Code Control", "Relationship", "Table Design", _
"Table Datasheet", "Query Design", "Filter/Sort", _
"Macro Design", "Utility 1", "Utility 2", "Page Design", _
"PivotTable", "PivotChart", "Query DataSheet", "Web", _
"Formatting (PivotTable" & Chr(47) & "PivotChart)")
CommandBars(varCb).Enabled = False
Next
End Sub

'Private Sub Form_Open(Cancel As Integer)
' Dim cb As CommandBar
' For Each cb In CommandBars
' cb.Enabled = True
' Debug.Print cb.Name
' Next
'End Sub



 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.