Disable Printing Icon Menu

  • Hi All

    I'm trying to disable my 'Print' button on the toolbar, to force users to 'validate' the information on a sheet before it's printed....

    Application.CommandBars("Standard").Controls("Print (\\NPR0042SFO\H4130SFO)").Enabled = False

    Here, the command works fine, but the control name has to contain the full path of my printer to work! If this is used by someone else connected to a different printer, it will fail.

    How can I get this to work for everyone? Would I need to find the name of everyone's printer first (I would need help with this), or could I use a wildcard 'Print*'?

    Can anyone help? Thanks.

  • Hi Rich,

    Rather than disable the print button, could you put your validation code in the Before_Print event in the ThisWorkbook

    Private Sub Workbook_BeforePrint(Cancel As Boolean)
     . . your validation code
    End Sub

    Then it would check no matter which printer is used.


  • Thought of something else, Rich

    Each control has in index number that can be used instead of the name - -

    CommandBars("File").Controls(15).Enabled = False
    ''.....turns off the print command on the File menu
    Application.CommandBars("Standard").Controls(6).Enabled = False
    ''......turns off the print button on the command bar

    Those index numbers worked on my system - - they may be different on other PC's depending on how the menus are set up - - but it might work for you.


  • Random ideas

    1) remove the toolbar
    2) disable right-clicking
    3) capture the ctrl+p event and override it (onkey?)


    <a href="http://www.mrexcel.com/relayforlife.shtml" target="new"><img src="http://www.myimgs.com/data/vonpookie/anne_relay.gif"></a>

  • rem1224: I tried this too, but foung that everyone's toolbar is different (my print icon is index 8). Thanks again.

    Iridium: I can't remove the toolbar because they still need to 'Save As...' after validation, and I built a custon right-click menu for the sheet. But thanks for the ideas.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!