Thread: Required Field
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Required Field

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Worksheets("Packing Slip").Range("U10") = "" Then '
Cancel = True
End If
End Sub

You have already hit the print button, so you don't need to do anything for
it to print. What you are doing is cancelling that print if U10 of Packing
Slip is blank.

Immediately after Cancel=True you might want to put in

Msgbox "Printing cancelled until you put a value in U10"



--
Regards,
Tom Ogilvy



"tiab86" wrote:


Ok,
I'm a bit confused.
When I put the values in below it appears to do nothing.
I'm new to VB so that's probably part of my problem.
What am I doing wrong?
I get the following error:


Run-time error '438':
Object doesn't support this property or method


Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Worksheets("Packing Slip").Range("U10") = "" Then '
Cancel = True
Print
End If
End Sub


--
tiab86
------------------------------------------------------------------------
tiab86's Profile: http://www.excelforum.com/member.php...o&userid=25628
View this thread: http://www.excelforum.com/showthread...hreadid=530950