XL: Printing Entire Workbook Prints Hidden Sheets

ID: Q136261


The information in this article applies to:
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for the Macintosh, versions 5.0, 5.0a
  • Microsoft Excel for Windows NT, version 5.0
  • Microsoft Excel for Windows 95, version 7.0


SUMMARY

In Microsoft Excel, if you print the entire workbook, all sheets are printed, including hidden sheets. This feature allows you to print hidden sheets without having to unhide and then re-hide them.

If you do not want to print all sheets, use any of the following methods.

Method 1:

Manually select all the sheets that you want to print either by pressing CTRL and clicking the desired sheet tabs or by clicking the first sheet tab and pressing SHIFT and clicking on the last sheet tab to select all the sheets in between. On the File menu, click Print. Click the Selected Sheets option
Method 2:
Use the following macro to print all of the visible sheets in the workbook.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/overview/overview.asp

Sample Visual Basic Procedure


   Sub Print_Visible_Sheets()
      Dim sht

      ' Turn off the screen redraw.
      Application.ScreenUpdating = False
      ' Loop through for all sheets in the workbook.
      For Each sht In Sheets
         ' If the current sheet is visible, then group it with the rest.
         If sht.Visible Then sht.Select Replace:=False
      Next

      ' Print all of the selected sheets.
      ActiveWindow.SelectedSheets.PrintOut copies:=1
      ' Ungroup the sheets.
      ActiveSheet.Select
      ' Turn back on the screen redraw.
      Application.ScreenUpdating = True
   End Sub 


MORE INFORMATION

This behavior is by design of Microsoft Excel.

Note that hiding a sheet is not a true form of document protection, because the sheet can be unhidden through the menu and there is no mechanism to keep someone from linking to or copying from a hidden sheet. One reason to use hidden sheets is to keep workbooks from becoming too cluttered.

Additional query words: 5.00c

Keywords : kbcode kbprg kbprint PgmOthr xlprint
Version : MACINTOSH:5.0,5.0a; WINDOWS:5.0,5.0c,7.0; winnt:5.0
Platform : MACINTOSH WINDOWS winnt
Issue type : kbinfo


Last Reviewed: November 9, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.