Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    122

    Unanswered: Disable button on custom menu bar

    What is an effective way to disable a button I have on a custom menu bar. I have replaced the toolbars/menu bars and would like to limit when my custom menu buttons can be used. Thanks for any help.

  2. #2
    Join Date
    Jul 2004
    Posts
    125
    1. You need to reference the Microsoft Office library because toolbars are part of the Office library.
    3. Here is an example of enabling or disabling toolbar buttons:

    '~ Called by forms and reports
    Public Function fnEnablePrintControl(ByVal bolLEnabled As Boolean)

    Dim objCmdBar As CommandBar, objCBControl As CommandBarControl, objSubCBControl As CommandBarControl
    Dim objCBControls As CommandBarControls, objCmdBars As CommandBars

    If Application.CommandBars(pStrApplName).Visible = True Then
    Set objCmdBar = Application.CommandBars(pStrApplName)
    End If

    MainToolBar:

    If bolLEnabled = True Then

    objCmdBar.Controls("&Database").Controls("C&ascade forms").Enabled = False
    objCmdBar.Controls("&Accounting").Enabled = False
    objCmdBar.Controls("&Print").Enabled = True

    Else

    objCmdBar.Controls("&Database").Controls("C&ascade forms").Enabled = True
    objCmdBar.Controls("&Accounting").Enabled = True
    objCmdBar.Controls("&Print").Enabled = False

    End If

    End Function

    P.S: There are variable declarations that do not belong to this procedure. Remove them as you will.

  3. #3
    Join Date
    Sep 2003
    Posts
    122
    Thank you for the help. I appreciate it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •