XL: Printing Entire Workbook Prints Hidden Sheets

Last reviewed: December 2, 1997
Article 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 engineers 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/refguide/default.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.00 5.00c 7.00
Keywords : kbcode kbprg kbprint xlprint PgmOthr
Version : WINDOWS:5.0,5.0c,7.0; MACINTOSH:5.0,5.0a
Platform : MACINTOSH WINDOWS
Issue type : kbinfo


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.