I am trying to disable the PRINT function being used be separate workbooks. The only time I want it to print is using an AddIn. I have attached an example. It shows the messagebox but then allow the Excel Print function to work without using the AddIn. Additionally, the AddIn is getting the messagebox.
Book1 in ThisWorkbook
Public Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = PrntOK
MsgBox "You can't print this workbook"
Exit Sub
End Sub
AddIn Code (partial)
Public Sub PrintDoc()
name = UCase(Application.UserName)
ctrlNbr = "12345"
PrntOK = True
Call PrintDocX(name, ctrlNbr)
PrntOK = False
End Sub
Bookmarks