Thread: Printing
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Martin Fishlock Martin Fishlock is offline
external usenet poster
 
Posts: 694
Default Printing

Hi,

You can do it all in the select statement checking for the true for the two
sheets.

I have introduced a variable cannotprint which is set to true if you cannot
print.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
dim connotprint as boolean
Select Case ActiveSheet.Name
Case "Input", "sheet1", "sheet2"
cannotprint=true
case "sheet3", "sheet4"
cannotprint = worksheets("sheet1").range("E162")
case else
cannotprint=true
end select
if cannotprint then
Cancel = connotprint
MsgBox "Sorry, you cannot print this page", vbInformation
end if
End Sub


Is it possible to amend this to add an If statement to do the following;

Look at cell E162 on sheet 1, if the value is True, sheets 3 and 4 now
print, but sheets 1 & 2 stay so they don't print?


--
Hope this helps
Martin Fishlock, Bangkok, Thailand
Please do not forget to rate this reply.


"Newbeetle" wrote:

Hi, Happy New Year to All

I use the code below that is placed in the ThisWorkbook to stop the printing
of certain sheets;

'Stops sheets printing as listed in Case
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Select Case ActiveSheet.Name
Case "Input", "sheet1", "sheet2", "sheet3", "sheet4"
Cancel = True
MsgBox "Sorry, you cannot print this page", vbInformation
End Select
End Sub

Is it possible to amend this to add an If statement to do the following;

Look at cell E162 on sheet 1, if the value is True, sheets 3 and 4 now
print, but sheets 1 & 2 stay so they don't print?

Hope that makes sense.

Regards

Newbeetle