CommandBars in Access 2002/2003

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • deko

    #1

    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("Me nu 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.


  • deko

    #2
    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(Cance l 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", "Relationsh ip", "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(var Cb).Enabled = False
    Next
    End Sub

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



    Comment

    Working...