View Single Post
  #9   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

Perhaps

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Const sPWORD As String = "autpbg1"
Dim ws As Worksheet
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
If Not Cancel Then
.Unprotect Password:=sPWORD
With .Range("A18:C18, A19:S48, G6:S15,N5:S5")
.Interior.ColorIndex = xlColorIndexNone
On Error Resume Next
Application.EnableEvents = False
.Parent.PrintOut
Application.EnableEvents = True
On Error GoTo 0
.Interior.ColorIndex = 37
End With
.Protect Password:=sPWORD
End If
End With
Cancel = True
End Sub



In article ,
pgarcia wrote:

Sir, could you help me with one more thing? Thanks