ALT+F11进入VBA编辑.在左侧列表栏里的thisworkbook上双击,添加以下代码
Private Sub Workbook_BeforePrint(Cancel As Boolean)
For Each a In ActiveSheet.UsedRange
If a.Text = "FALSE" Then
Cancel = True
MsgBox "有错,退出打印!"
End If
Next
End Sub
不要用自带的打印,增加打印控制事件
sub 打印()
''''如某单元格为A1
if [a1]=false then
msgbox "有错误!"
exit sub
end if
Application.Dialogs(xlDialogPrinterSetup).Show
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
end sub