title: How to get text by page from word file (.Docx) using Microsoft.Office.Interop.Word in C#
body: <p>i want to extract text from .DOCX file by page using Microsoft.Office.Interop.Word in C#. </p>
  
  <p>currently i am getting all the text of file by the method as mentioned below but i want it page by page so how can i do this</p>
  
  <pre><code>public void ImportWordFile()
      {
  
          object path = @"C:\Users\Vipin\Desktop\test.docx";
  
          Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application();
          object miss = System.Reflection.Missing.Value;
          object readOnly = true;
          Microsoft.Office.Interop.Word.Document docs = word.Documents.Open(ref path, ref miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
          string totaltext = "";
          for (int i = 0; i &lt; docs.Paragraphs.Count; i++)
          {
              totaltext += " \r\n " + docs.Paragraphs[i + 1].Range.Text.ToString();
          }
          var numberOfPages = docs.ComputeStatistics(Word.WdStatistic.wdStatisticPages, false);
          Debug.Write("WordFileText = " + numberOfPages);
          docs.Close();
          word.Quit();
  
  
  
      }
  </code></pre>