Consulting

Results 1 to 9 of 9

Thread: Disable print

  1. #1
    VBAX Regular
    Joined
    Dec 2004
    Posts
    26
    Location

    Disable print

    Is it possible to disable the print icon on the toolbar. I can turn it off in the File menu, but cannot seem to get it right for the toolbar.

    Thanks for helping.

    Outrider.

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Try this code.


    Option Explicit
     
     Sub DisablePrint()
    Dim CmdBar          As CommandBar
         Dim CmdCtl          As CommandBarControl
    For Each CmdBar In CommandBars
             Set CmdCtl = CmdBar.FindControl(ID:=2521, recursive:=True)
             If Not CmdCtl Is Nothing Then
                 CmdCtl.Enabled = False
             End If
         Next CmdBar
    Set CmdBar = Nothing
         Set CmdCtl = Nothing
    End Sub

  3. #3
    VBAX Regular
    Joined
    Dec 2004
    Posts
    26
    Location
    Thanks DRJ,

    Which bit turns it back on again?

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    CmdCtl.Enabled = True

  5. #5
    VBAX Regular
    Joined
    Dec 2004
    Posts
    26
    Location
    Thanks again Jake, it works great.

  6. #6
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You're Welcome

    Take Care

  7. #7
    VBAX Contributor Richie(UK)'s Avatar
    Joined
    May 2004
    Location
    UK
    Posts
    188
    Location
    ... and what if the user of your workbook wants to print from another workbook that they have open?

    Generally I would advise against altering the user's Excel setup (hiding menus/menu items, disabling shortcut keys etc - Had you considered Ctrl&P ?). This can be extremely frustrating.

    As an alternative, how about using the BeforePrint event in the workbook concerned (Cancel=True)? Just a thought

  8. #8
    VBAX Regular
    Joined
    Dec 2004
    Posts
    26
    Location
    Richie,

    The users have no other workbooks. It is important to limit their ability to use the file menu or toolbar so that they use a macro that performs many other functions as well as print out the document they need. Ctrl + P is not that much of a problem because most of them do not know about it.

    Outrider.

  9. #9
    VBAX Contributor
    Joined
    Dec 2004
    Posts
    122
    Location
    You could also put this code in your workbook code.


    Private Sub Workbook_BeforePrint(Cancel As Boolean)
     MsgBox "Printing is disabled in this workbook."
     Cancel = True
     End Sub
    That way It will only work for this workbook. I hope.

Posting Permissions

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