Microsoft KB Archive/127206

= Macro to Print Notes/Comments as Separate Printout =

Article ID: 127206

Article Last Modified on 10/10/2006

-

APPLIES TO


 * Microsoft Excel 95a
 * Microsoft Excel 5.0c
 * Microsoft Excel 5.0 Standard Edition
 * Microsoft Excel 5.0a for Macintosh

-



This article was previously published under Q127206



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. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to 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 requirements. 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:

112221 Printing Cell Notes as Separate Printout

