title: Set background color of headers and footers
body: <p>I have been able to change the background color of Word tables in the body of the document with: <code>oSourceTable.Shading.BackgroundPatternColor = wdRed</code>. However, the same code does not work for header or footer Word tables. I have also tried setting the Section back color as well, but to no avail. The code runs, but the Headers and Footers are always displayed with white backgrounds. </p>
  
  <p>I have done mostly Excel VBA, and only a little bit of Word VBA so maybe I am missing something obvious here. Thanks in advance for any ideas and/or suggestions.</p>
  
  <p>As requested, here is the code I am using. vTableBackColors is just an array of colors. This code is for the body tables and is working perfectly.</p>
  
  <pre><code>For Each oWordTable In oWordDoc.Tables
      lIndex = lIndex + 1
      oWordTable.Shading.BackgroundPatternColor = vTableBackColors(lIndex)
  Next 
  </code></pre>
  
  <p>I tried to do the same thing for the header and footer tables, but it does not work. I tried using the Header/Footer tables as below.</p>
  
  <pre><code>For Each oWordSection In oWordDoc.Sections
      For Each oWordTable In oWordSection.Headers.Item(wdHeaderFooterPrimary).Range.Tables
          ' I selected this one to see if it would make a difference.
          oWordTable.Select
          oWordTable.Shading.BackgroundPatternColor = m_HeaderBackColor
      Next
      For Each oWordTable In oWordSection.Footers.Item(wdHeaderFooterPrimary).Range.Tables
          oWordTable.Shading.BackgroundPatternColor = m_FooterBackColor
      Next
  Next
  </code></pre>
  
  <p>I also tried using the Section Headers / Footers directly. Before and after checking shows that the BackgroundPatternColor has changed as desired, but it is not displayed. </p>
  
  <pre><code>oWordSection.Headers.Item(wdHeaderFooterPrimary).Range.Shading.BackgroundPatternColor = m_HeaderBackColor
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/U48cp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U48cp.png" alt="enter image description here"></a></p>
  
  <p>Here is a screenshot showing the colorized body tables and the unchanged header.
  Is it possible that, unlike the Body table colors, the Header / Footer colors are never displayed as such by the Word designer, but are only true at runtime? </p>
  
  <p>Thanks for any additional information.</p>