whereswayno
New Member
- Joined
- Aug 7, 2011
- Messages
- 3
This is very frustrating. I am using a Windows 7 machine with Excel 2010. I want to cancel printing a worksheet if there are too many pages. Thus I understand that I need to have code as follows:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If PageSetup.Pages > 2 then
Cancel = True
MsgBox "Please change the print area into ONLY 2 pages.", vbInformation
End If
End Sub
However, none of this code is being run when the print icon is pressed or when someone clicks File -> Print -> Print. I went to the trust center and verified that all macros are enabled and that access to the VBA project module was trusted too. I verified that I saved the project before trying to click the print icon.
In case my code was incorrect, I simplified it:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
MsgBox "Please change the print area into ONLY 2 pages.", vbInformation
End Sub
I never received this message, so none of it ran.
Does anyone have any ideas how to fix this?
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If PageSetup.Pages > 2 then
Cancel = True
MsgBox "Please change the print area into ONLY 2 pages.", vbInformation
End If
End Sub
However, none of this code is being run when the print icon is pressed or when someone clicks File -> Print -> Print. I went to the trust center and verified that all macros are enabled and that access to the VBA project module was trusted too. I verified that I saved the project before trying to click the print icon.
In case my code was incorrect, I simplified it:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
MsgBox "Please change the print area into ONLY 2 pages.", vbInformation
End Sub
I never received this message, so none of it ran.
Does anyone have any ideas how to fix this?