Disable Print Facility

atmospheric

Well-known Member
Joined
Jul 16, 2002
Messages
565
I have a spreadsheet with a print button which allows the user to print only the parts I want them to see. I have removed the Printer icon on the toolbar, but does anyone know how to remove the Print option on the File menu? (File/Print)

Thanks in advance
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Sorry to bring this back to life after soooooooo long but need help with this!

When I do what is advised I get runtime error 1004 "cannot run the macro "enablefilechoices". The macro may not be available in this workbook or all macros may be disabled.
 
Upvote 0
I have used the following code now in the workbook code:

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
    Cancel = True
    MsgBox "Preview and Print are not allowed.  Please use the Print Paperwork buttton.", vbCritical, "PRINT DISABLED"
End Sub

However this is now interferring with my command button which has this code:

Code:
Private Sub CommandButton1_Click()

    If Sheets("BANKING DEPOSIT").Range("O2") <> "" _
        And Sheets("BANKING DEPOSIT").Range("B7") <> "" _
        And Sheets("BANKING DEPOSIT").Range("B9") <> "" Then
        ActiveWorkbook.PrintOut
    Else
        MsgBox "Select a date and enter the bag numbers before printing, Thanks!"
    End If
End Sub

Can I add anything to the above code so it allows the workbook to print of the command button? Thanks guys
 
Upvote 0
"Untested" but see if adding a Public boolean flag can do what you want as follows :

In the workbook module:

Code:
Public bFlag as boolean
 
Private Sub Workbook_BeforePrint(Cancel As Boolean)
 
    if  Not bFlag then 
       Cancel = True
       MsgBox "Preview and Print are not allowed.  Please use the Print         Paperwork buttton.", vbCritical, "PRINT DISABLED"
   end if
 
End Sub



Code:
Private Sub CommandButton1_Click()
 
If Sheets("BANKING DEPOSIT").Range("O2") <> "" _
    And Sheets("BANKING DEPOSIT").Range("B7") <> "" _
    And Sheets("BANKING DEPOSIT").Range("B9") <> "" Then
    bFlag =True
    ActiveWorkbook.PrintOut
    bFlag=False
Else
    MsgBox "Select a date and enter the bag numbers before printing, Thanks!"
End If
 
End Sub
Regards.
 
Last edited:
Upvote 0
I get the same error when trying to print using the command button as I do when trying from the file menu, any ideas?
 
Upvote 0

Forum statistics

Threads
1,215,325
Messages
6,124,252
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top