XL: Macro to Print Notes/Comments as Separate Printout

Last reviewed: December 1, 1997
Article ID: Q127206
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, versions 7.0, 7.0a

SUMMARY

When the Notes check box on the Sheet tab in Page Setup is selected, Microsoft Excel will print the document first, and then it will print the Notes of the document. In order to print the Notes only, you must determine the page numbers of the Notes and print those pages only.

The following is a sample Visual Basic for Applications macro you can use to print only the Notes for each selected worksheet.

MORE INFORMATION

The following macro uses the Microsoft Excel 4.0 macro function GET.DOCUMENT(50) to determine the number of pages in the document. It also uses the function GET.DOCUMENT(51) to determine the number of pages of Notes that will be printed. It uses these functions to determine the page numbers to print.

Visual Basic Code Example

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

On a module sheet, type the macro below. After you create the macro, select the worksheet that you want to print the notes for and choose Macro from the Tools menu. Select the print_notes macro and choose Run.

   Sub Print_Notes()
      ' Get the current selected sheets.
      Set MySheets = ActiveWindow.SelectedSheets

      ' Loop through all sheets that are selected.
      For Each PrintSheet in MySheets
         PrintSheet.Select
         ' Get the current setting for Notes in Page Setup.
         CurrSet = ActiveSheet.PageSetup.PrintNotes

         ' Set the notes in Page Setup to True.
         ActiveSheet.PageSetup.PrintNotes = True

         ' Get the number of pages to print without notes.
         NumPages = ExecuteExcel4Macro("GET.DOCUMENT(50)")

         ' Get the number of pages of notes that will print.
         NotesPages = ExecuteExcel4Macro("GET.DOCUMENT(51)")

         ' Print only the notes pages.
         If NotesPages > 0 Then
            ActiveWindow.SelectedSheets.PrintOut _
               From:=NumPages + 1, To:=NumPages + NotesPages
            ' Reset the notes setting in Page Setup.
             ActiveSheet.PageSetup.PrintNotes = CurrSet
         End If
      Next
      ' Regroup the sheets.
      MySheets.Select
   End Sub

For more information about Notes, choose the Search button in Help and type:

     Notes

For additional information, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q112221
   TITLE     : Printing Cell Notes as Separate Printout

REFERENCES

"User's Guide," version 5.0, page 676


Additional query words: 5.00 5.00a 5.00c 7.00 7.00a XL7 XL5 seperate
Keywords : kbcode kbprg PgmHowto PgmPrt
Version : WINDOWS:5.0,5.0c,7.0; MACINTOSH:5.0,5.0a
Platform : MACINTOSH WINDOWS
Issue type : kbhowto


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 1, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.