How to: Print Documents
You can print an entire Microsoft Office Word document, or part of a document.
Applies to: The information in this topic applies to document-level projects and application-level projects for Word 2007 and Word 2010. For more information, see Features Available by Office Application and Project Type.
Printing a Document That Is Part of a Document-Level Customization
To print the entire document
Call the PrintOut method of the ThisDocument class in your project to print the entire document. To use this example, run the code from the ThisDocument class.
Me.PrintOut()
object copies = "1"; object pages = ""; object range = Word.WdPrintOutRange.wdPrintAllDocument; object items = Word.WdPrintOutItem.wdPrintDocumentContent; object pageType = Word.WdPrintOutPages.wdPrintAllPages; object oTrue = true; object oFalse = false; this.PrintOut(ref oTrue, ref oFalse, ref range, ref missing, ref missing, ref missing, ref items, ref copies, ref pages, ref pageType, ref oFalse, ref oTrue, ref missing, ref oFalse, ref missing, ref missing, ref missing, ref missing);
To print the current page of the document
Call the PrintOut method of the ThisDocument class in your project and specify that one copy of the current page be printed. To use this example, run the code from the ThisDocument class.
Me.PrintOut( _ Background:=True, _ Append:=False, _ Range:=Word.WdPrintOutRange.wdPrintCurrentPage, _ Item:=Word.WdPrintOutItem.wdPrintDocumentContent, _ Copies:="1", _ Pages:="1", _ PageType:=Word.WdPrintOutPages.wdPrintAllPages, _ PrintToFile:=False, _ Collate:=True, _ ManualDuplexPrint:=False)
object copies = "1"; object pages = "1"; object range = Word.WdPrintOutRange.wdPrintCurrentPage; object items = Word.WdPrintOutItem.wdPrintDocumentContent; object pageType = Word.WdPrintOutPages.wdPrintAllPages; object oTrue = true; object oFalse = false; this.PrintOut( ref oTrue, ref oFalse, ref range, ref missing, ref missing, ref missing, ref items, ref copies, ref pages, ref pageType, ref oFalse, ref oTrue, ref missing, ref oFalse, ref missing, ref missing, ref missing, ref missing);
Printing a Document By Using an Application-Level Add-In
To print an entire document
Call the PrintOut 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 ThisAddIn class in your project.
Me.Application.ActiveDocument.PrintOut()
this.Application.ActiveDocument.PrintOut(true, false, Word.WdPrintOutRange.wdPrintAllDocument, Item: Word.WdPrintOutItem.wdPrintDocumentContent, Copies:"1", Pages:"", PageType:Word.WdPrintOutPages.wdPrintAllPages, PrintToFile:false, Collate:true, ManualDuplexPrint:false);
To print the current page of a document
Call the PrintOut 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 ThisAddIn class in your project.
Me.Application.ActiveDocument.PrintOut( _ Background:=True, _ Append:=False, _ Range:=Word.WdPrintOutRange.wdPrintCurrentPage, _ Item:=Word.WdPrintOutItem.wdPrintDocumentContent, _ Copies:="1", _ Pages:="1", _ PageType:=Word.WdPrintOutPages.wdPrintAllPages, _ PrintToFile:=False, _ Collate:=True, _ ManualDuplexPrint:=False)
object copies = "1"; object pages = "1"; object range = Word.WdPrintOutRange.wdPrintCurrentPage; object items = Word.WdPrintOutItem.wdPrintDocumentContent; object pageType = Word.WdPrintOutPages.wdPrintAllPages; object oTrue = true; object oFalse = false; Word.Document document = this.Application.ActiveDocument; document.PrintOut( ref oTrue, ref oFalse, ref range, ref missing, ref missing, ref missing, ref items, ref copies, ref pages, ref pageType, ref oFalse, ref oTrue, ref missing, ref oFalse, ref missing, ref missing, ref missing, ref missing);
See Also
Tasks
How to: Display Documents in Print Preview