title: Find the number of pages in a Word document Section using Interop
body: <p>I'm trying to find the number of pages in a Section of a Word document using Interop in c#.</p>
  
  <p>The main goal is really to find out if a header is visible or not. (E.g. a document is only 1 page, the <code>DifferentFirstpageHeaderFooter</code> is enabled, so the <code>wdHeaderFooterPrimary</code> exists but is technically not shown (because there's only 1 page and not 2 or more).) So if you can find a different way to figure out how to do this, I'm fine with that too.</p>
  
  <p>Currently, <code>WdInformation.wdActiveEndPageNumber</code> works if there is only 1 section in the document, but if there is 2, and I'm doing the processing of the second section, <code>wdActiveEndPageNumber</code> gives me the total number of pages including section 1.</p>
  
  <pre><code>var section = headerFooter.Parent as Section;
  int numOfPages = section.Range.Information[WdInformation.wdActiveEndPageNumber];
  </code></pre>