Before Print

P

peabrain25

Hello,
I am working with a worksheet in which I have inserted a button to print a
form. The button runs a macro which calls a function to check for errors
(missing fields, incorrect data, etc.). If all is well, the form prints. My
problem is that people can still use File, Print to print the form without
checking for errors first. I have tried using the Before_Print object to stop
this from happening by telling it to run the print macro I wrote before
printing everything. The problem with that is that now either two forms print
(one from the File, Print and one from the print macro), or no form prints
(when I set Cancel to be true). Is there a way to disable the manual printing
capabilities for users or is there another way around this? Thanks!
 
R

Ron de Bruin

Use this for "Sheet1"

This example print if there is a value in A1

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
Cancel = True
Application.EnableEvents = False
Application.ScreenUpdating = False
With ActiveSheet
If Range("A1") <> "" Then
.PrintOut
End If
End With
Application.EnableEvents = True
Application.ScreenUpdating = True
End If
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