title: Word VBA Getting page number of a specific footer in section
body: <p>Couldn't find the answer I was looking for.</p>
  
  <p>I want to get the current page number String including its format.<br>
  For example: Some sections may have chapter identifier (1-1), some are in Roman style, etc..  </p>
  
  <p>My hope was to get the selection of the specific footer, then loop through the fields and get the Page field data (Output is the String I want).  </p>
  
  <p>So far as I can see, there is no option to loop through the footers of a given section, just get the general template and try working with it.<br>
  I'm aware of <code>wdActiveEndAdjustedPageNumber</code> from <code>Selection.Range.Information</code>, but it just gives me partial information.  </p>
  
  <p>Am I wrong? Is there a way to work with a specific footer I choose?<br>
  If not, can you guide me how to get the following data:</p>
  
  <ul>
  <li>Closest chapter number value</li>
  <li>Getting the page number value of a special format such as Roman, Alphabetical font (Meaning applying the page format on the <code>wdActiveEndAdjustedPageNumber</code>)</li>
  </ul>
  
  <p>Thanks.</p>
  
  <p><strong>Edit for clarification:</strong>  </p>
  
  <ol>
  <li><p>In my word template, the Heading 1 style creates the following header: <strong>Chapter 1</strong>, followed by Chapter 2 and so on.<br>
  In page number format, there is an option to include the current Chapter value to the page number.<br>
  For example: Assuming the following setup  </p>
  
  <p><a href="https://i.stack.imgur.com/ioKul.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ioKul.png" alt="Page Number format"></a><br>
  will result with these pages in the <code>{ PAGE }</code> field: 1-1, 1-2, 1-3, ...
  My goal is to somehow get this entire "value" for a specific page footer.<br>
  Here is a code snippet which <strong>won't</strong> work properly:</p>
  
  <pre><code>Sub getPageFieldInFooter()
  ' get current section number
  Dim sectionNum As Integer
  sectionNum = Selection.Range.Information(wdActiveEndSectionNumber)
  'select first page footer, loop through its fields and find Page field
  ActiveDocument.Sections(sectionNum).Footers(wdHeaderFooterPrimary).Range.Select
  Dim f As Field
  For Each f In Selection.Fields
      If f.Type = wdFieldPage Then
          ' do something with the page data
          MsgBox f.Data
      End If
  Next f
  End Sub
  </code></pre>
  
  <p>The output of such a method is '1-1'<br>
  The reason it won't work is because it can retrieve the first page only (or the second using <code>wdHeaderFooterEvenPages</code>). </p></li>
  <li><p>Same goes for Roman number format, or any other from that list.<br>
  For the following page number settings, I wish to get the "value" in a specific footer.<br>
  The code above will return the values for first or second page, and that's it.
  <a href="https://i.stack.imgur.com/6t0RR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6t0RR.png" alt="Roman Number format"></a></p></li>
  </ol>
  
  <p>Is there a way to access any footer in the document and perform my code example?<br>
  If not, how can I get the page number "value" for any footer I choose?<br>
  Hope this is clearer. </p>