Hide Print option from File Menu

H

Harish

I am trying to disable and hide the "Print" option from "File Menu".Also I
want to disable "CTRL + P" and Print icon from standard tool bar.

I have written the code as follow but it's not working.It's coming with an
error that" Invalid procedure call or argument."

Sub Macro1()

Sheets("Sheet1").Select
Application.CommandBars.Item("File").Controls.Item("Print").Enabled = False
Application.CommandBars.Item("File").Controls.Item("Print").Visible = False

End Sub


Thanks in advance.

Harish
 
B

Bearacade

Why not just put this in ThisWorkbook:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
End Sub
 
B

Bearacade

I won't mess with making thing invisible or disable, you are just
opening a can of worms, (having to set it back to visible and enable
when people exit your spreadsheet
 
J

Jim Thomlinson

As a different approach to the problem have you considered using the before
print event in this workbook. Something like this will disable the ability to
print in this workbook without affecting the entire application and other
open spreadsheets... there is also no need for strong error handling to
reseth the buttons in case the spreadsheet crashes...

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
MsgBox "Sorry. Printing of this spreadhseet is " & _
"not allowed", vbInformation, "Printing Cancelled"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top