PrintOut Method (Application, Document, and Window Objects)
Applies To
Application object, Document object, Window object.
Description
Prints all or part of the specified document. The arguments for this method correspond to the options in the Print dialog box (File menu).
Syntax
expression.PrintOut(Background, Append, Range, OutputFileName, From, To, Item,
Copies, Pages, PageType, PrintToFile, Collate, FileName, ActivePrinterMacGX,
ManualDuplexPrint)
expression Required. An expression that returns an Application, Document, or Window object.
Background Optional Variant. True to have the macro continue while Word prints the document.
Append Optional Variant. True to append the specified document to the file name specified by the OutputFileName argument. False to overwrite the contents of OutputFileName.
Range Optional Variant. The page range. Can be one of the following WdPrintOutRange constants: wdPrintAllDocument, wdPrintCurrentPage, wdPrintFromTo, wdPrintRangeOfPages, or wdPrintSelection.
OutputFileName Optional Variant. If PrintToFile is True, this argument specifies the path and file name of the output file. This argument isn't available on the Macintosh unless QuickDraw GX is installed.
From Optional Variant. The starting page number when Range is set to wdPrintFromTo.
To Optional Variant. The ending page number when Range is set to wdPrintFromTo.
Item Optional Variant. The item to be printed. Can be one of the following WdPrintOutItem constants: wdPrintAutoTextEntries, wdPrintComments, wdPrintDocumentContent, wdPrintKeyAssignments, wdPrintProperties, or wdPrintStyles.
Copies Optional Variant. The number of copies to be printed.
Pages Optional Variant. The page numbers and page ranges to be printed, separated by commas. For example, "2, 6 – 10" prints page 2 and pages 6 through 10.
PageType Optional Variant. The type of pages to be printed. Can be one of the following WdPrintOutPages constants: wdPrintAllPages, wdPrintEvenPagesOnly, or wdPrintOddPagesOnly.
PrintToFile Optional Variant. True to send printer instructions to a file. Make sure to specify a file name with OutputFileName. This argument isn't available on the Macintosh unless QuickDraw GX is installed.
Collate Optional Variant. When printing multiple copies of a document, True to print all pages of the document before printing the next copy.
FileName Optional Variant. The path and file name of the document to be printed. If this argument is omitted, Word prints the active document. Available only with the Application object.
ActivePrinterMacGX Optional Variant. On the Macintosh, if QuickDraw GX is installed, specifies the printer to print to.
ManualDuplexPrint Optional Variant. Not used in the U.S. English version of Microsoft Word.
See Also
ActivePrinter property, PageSetup property, PrintFractionalWidths property.
Example
This example prints the current page of the active document.
ActiveDocument.PrintOut Range:=wdPrintCurrentPage
This example prints all the documents in the current folder. The Dir function is used to return all file names that have the file name extension ".doc".
adoc = Dir("*.DOC")
While adoc <> ""
Application.PrintOut FileName:=adoc
adoc = Dir()
Wend
This example prints the first three pages of the document in the active window.
ActiveWindow.PrintOut Range:=wdPrintFromTo, From:="1", To:="3"
This example prints the comments in the active document.
If ActiveDocument.Comments.Count >= 1 Then
ActiveDocument.PrintOut Item:=wdPrintComments
End If