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.
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.
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
Thanks DRJ,
Which bit turns it back on again?
CmdCtl.Enabled = True
Thanks again Jake, it works great.
You're Welcome
Take Care
... 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
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.
You could also put this code in your workbook code.
That way It will only work for this workbook. I hope.Private Sub Workbook_BeforePrint(Cancel As Boolean) MsgBox "Printing is disabled in this workbook." Cancel = True End Sub