View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Printing with restrictions - VB

Since you're checking individual cells, this might be easier:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim vCheck As Variant
Dim i As Long
Dim nAddr As Long
Dim nMsg As Long

vCheck = Array( _
Array("K7", "a date in 'Request Date' field"), _
Array("K11", _
"to choose a Mgr. from the 'Mgr. Approval' dropdown list"), _
Array("K14", _
"an amount in the 'Total Amount to be Reallocated' field"), _
Array("D26", "a number in the 'Receipt Number'"))

nAddr = LBound(vCheck)
nMsg = nAddr + 1

With Sheets("Receipt to Receipt")
For i = LBound(vCheck) To UBound(vCheck)
Cancel = Trim(.Range(vCheck(i)(nAddr)).Text) = vbNullString
If Cancel Then
MsgBox "You need " & vCheck(i)(nMsg) & " before printing!"
Exit For
End If
Next i
End With
End Sub


In article ,
pgarcia wrote:

JE, I seem to have found a problem. I'm not getting the form back form the
field and I noted that on the fields that I wanted filled out is not being
filled out. This is what I found, when the user gets the msg box and click
"ok", then can go back to the field type something there and then remove it
(I'm not sure how there doing this) and they can then print the form. Please