Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Having a similar problem where I never wanted a selected sheet to
print. The solutions posted at best still printed something when the sheet that I did not want to print was active. I used the following code to alway block the printing of "Sheet1" in the example where the workbook has three (3) sheets: Private Sub Workbook_BeforePrint(Cancel As Boolean) If ActiveSheet.Name = "Sheet1" Then MsgBox "Print Error, Unable to Print Sheet1", vbCritical Cancel = True Else If ActiveSheet.Name = "Sheet2" Or ActiveSheet.Name = "Sheet3" Then Application.DisplayAlerts = False Application.EnableEvents = False ThisWorkbook.Worksheets("Sheet1").Visible = xlVeryHidden Application.Dialogs(xlDialogPrint).Show ThisWorkbook.Worksheets("Sheet1").Visible = xlSheetVisible Application.DisplayAlerts = True Application.EnableEvents = True Cancel = True End If End If End Sub The down side of this solution is that one must list all other workbook sheets in the line following the "Else" statement. The "Cancel" command near the end of the code was necessary to prevent two (2) sheets from printing. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Workbook_BeforeClose(Cancel As Boolean) - Cancel won't work | Setting up and Configuration of Excel | |||
printing a worksheet | Excel Discussion (Misc queries) | |||
Printing worksheet | New Users to Excel | |||
Worksheet printing | Excel Worksheet Functions | |||
printing worksheet | Excel Discussion (Misc queries) |