private void spust_Click(object sender, RoutedEventArgs e) { Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass(); // File Path string strFilePath = "C:/TestRead.doc"; // Create obj filename to pass it as paremeter in open object objFile = strFilePath;object objNull = System.Reflection.Missing.Value; object objReadOnly = true; //Open Document Microsoft.Office.Interop.Word.Document Doc = wordApp.Documents.Open(ref objFile, ref objNull, ref objReadOnly, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull, ref objNull); // To read each line consider each line as paragraph Docuemnt int i = 1; foreach (Microsoft.Office.Interop.Word.Paragraph objParagraph in Doc.Paragraphs) { try {lblName.Content += Doc.Paragraphs[i].Range.Text;#########--> CurrentPage = Microsoft.Office.Interop.Word.WdFieldType.wdFieldPage; //CurrentPage contains current page number ######### }catch (Exception ex){throw ex;}i++; } // close document and Quit Word Application Doc.Close(ref objNull, ref objNull, ref objNull); wordApp.Quit(ref objNull, ref objNull, ref objNull); }
It would be perfect if you can suggest me how to get page number.
Thanks a lot!