[AccessD] Access Toolbars

Ken Ismert KIsmert at TexasSystems.com
Fri Dec 5 14:09:17 CST 2003


Paul,

This is my second try. The first email didn't make it, somehow.

Here are some routines I have written that may help.

* ShowMenuBar hides/shows the main menu bar
* ShowCommandBars displays all menu bars, and lets you search for a name
* ShowCBarControls displays all controls for a specified menu bar

Notes:

* You will need a reference to the Microsoft Office Object Library,
appropriate to the version you're using
* These routines will work in almost any Office program.

- Ken

<code>

Public Sub ShowMenuBar(fVisible As Boolean)

    Dim cBar As Office.CommandBar

    Set cBar = CommandBars("Menu Bar")

    cBar.Visible = fVisible

End Sub

Public Sub ShowCommandBars(Optional strLike As String = "*")

    Dim strOut As String
    Dim cBar As Office.CommandBar

    If Right$(strLike, 1) <> "*" Then
        strLike = strLike & "*"
    End If

    strOut = "CommandBars" & IIf(strLike = "*", ": ", " Like '" & strLike &
"':") & vbCr & vbCr

    For Each cBar In Application.CommandBars
        If cBar.Name Like strLike Then
            strOut = strOut & cBar.Name & ";  Index:=" & cBar.Index & ";
Type:=" & cBar.Type & vbCr
        End If
    Next

    MsgBox strOut

End Sub

Public Sub ShowCBarControls(CBarName As String)

    Dim strOut As String
    Dim ctl As Office.CommandBarControl
    Dim cBar As Office.CommandBar

    On Error GoTo HandleErr

    Set cBar = Application.CommandBars(CBarName)

    strOut = cBar.Name & " Controls: " & vbCr & vbCr

    For Each ctl In cBar.Controls
        strOut = strOut & ctl.Caption & ";  ID-" & ctl.ID & ";  Type-" &
ctl.Type & vbCr
    Next

Resume_ShowControls:
    MsgBox strOut

    Exit Sub

HandleErr:
    strOut = "Commandbar '" & CBarName & "' not found."
    Resume Resume_ShowControls
End Sub

</code>


-----Original Message-----
From: paul.hartland at fsmail.net [mailto:paul.hartland at fsmail.net]
Sent: Thursday, December 04, 2003 4:56 AM
To: accessd
Subject: [AccessD] Access Toolbars


To all,

For the life of me I can’t see how to hide an Access toolbar via VBA code, I
’m pretty sure you can do it.  Basically I want to hide all the built in
Access toolbars when the user logs into the application, and only display my
custom ones.

Could somebody please save my brainache and tell e how to do this

.

Thanks in advance (once more forever in debt to the list)

Paul Hartland
Database Designer/Developer.
Freeserve AnyTime - HALF PRICE for the first 3 months - Save £7.50 a month
www.freeserve.com/anytimeFrom paul.hartland at fsmail.net Thu Dec  4 05:12:00
2003



More information about the AccessD mailing list