We can use can use the PrintOut method to print a Microsoft Office Word document, following example code shows how to print one copy of the current page of the word document in vb.net and c# languages:
Code Sample :
[vb.net]
Private Sub PrintCurrentpageInWordDocument() Dim objWord As Word.Application Dim objDoc As Word.Document objWord = CreateObject("Word.Application") objDoc = objWord.Documents.Open("D:\Test.docx") objDoc.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) objDoc.Close() objDoc = Nothing objWord.Quit() End Sub
[c#]
private void PrintCurrentpageInWordDocument() { object objMissing = System.Reflection.Missing.Value; Microsoft.Office.Interop.Word.Application objWord; Microsoft.Office.Interop.Word.Document objDoc; objWord = new Microsoft.Office.Interop.Word.Application(); object fileName = @"D:\Test.docx"; objDoc=objWord.Documents.Open(ref fileName, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing); object copies = "1"; object pages = "1"; object range = Microsoft.Office.Interop.Word.WdPrintOutRange.wdPrintCurrentPage; object items = Microsoft.Office.Interop.Word.WdPrintOutItem.wdPrintDocumentContent; object pageType = Microsoft.Office.Interop.Word.WdPrintOutPages.wdPrintAllPages; object objTrue = true; object objFalse = false; objDoc.PrintOut( ref objTrue, ref objFalse, ref range, ref objMissing, ref objMissing, ref objMissing, ref items, ref copies, ref pages, ref pageType, ref objFalse, ref objTrue, ref objMissing, ref objFalse, ref objMissing, ref objMissing, ref objMissing, ref objMissing); }