How to: Programmatically Print Documents
You can print an entire Microsoft Office Word document, or part of a document, to your default printer.
Applies to: The information in this topic applies to document-level projects and VSTO add-in projects for Word. For more information, see Features Available by Office Application and Project Type.
To print the entire document
Call the PrintOut method of the
ThisDocumentclass in your project to print the entire document. To use this example, run the code from theThisDocumentclass.
To print the current page of the document
Call the PrintOut method of the
ThisDocumentclass in your project and specify that one copy of the current page be printed. To use this example, run the code from theThisDocumentclass.
To print an entire document
Call the M:Microsoft.Office.Interop.Word._Document.PrintOut(System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@) method of the Microsoft.Office.Interop.Word.Document object that you want to print. The following code example prints the active document. To use this example, run the code from the
ThisAddInclass in your project.
To print the current page of a document
Call the M:Microsoft.Office.Interop.Word._Document.PrintOut(System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@,System.Object@) method of the Microsoft.Office.Interop.Word.Document object that you want to print, and specify that one copy of the current page be printed. The following code example prints the active document. To use this example, run the code from the
ThisAddInclass in your project.