title: Accessing shape in current page header
body: <p>I have a word document with multiple sections that contains some "separator pages," which are pages with a page-filling rectangle in the page header, so that they can use a user-defined background color.
  These background colors I would like to be able to change via a macro that should be run when the user doubleclicks on a seperator page.</p>
  
  <p>This kind of works (yes, I'm sure the code could be written a bit nice with a <code>With</code> block or so (I'm a C# guy, this is just a side project):</p>
  
  <pre class="lang-vb prettyprint-override"><code>Private Sub App_WindowBeforeDoubleClick(ByVal Sel As Selection, Cancel As Boolean)    
      Dim sectionNumber As Long
  
      sectionNumber = ActiveDocument.ActiveWindow.Selection.Information(wdActiveEndSectionNumber)
  
      Dim i As Integer
      Dim shapeCount As Integer
      shapeCount = ActiveDocument.Sections(sectionNumber).Headers(wdHeaderFooterPrimary).Shapes.Count
      For i = 1 To shapeCount
          ActiveDocument.Sections(sectionNumber).Headers(wdHeaderFooterPrimary).Shapes(i).Fill.ForeColor.RGB = RGB(255, 0, 0)
          ActiveDocument.Sections(sectionNumber).Headers(wdHeaderFooterPrimary).Shapes(i).Fill.BackColor.RGB = RGB(255, 0, 0)
      Next i
  End Sub
  </code></pre>
  
  <p>Of course I still need to add code to detect whether the user actually doubleclicked on a separator page etc.</p>
  
  <p>But the big problem now is that the header contains the shapes for <strong>ALL</strong> seperator pages, not just the current one, even though they're in different sections!</p>
  
  <p>And they're not even necessarily in the order they appear in the document, it seems. So how can I find the shape for the current separator page?</p>