title: Office 2007 [and higher] interop: retrieve RGB-color
body: <p><br>
  <strong>UPDATE:</strong> If you need to determine rgb-color in office document (format 2007) look at my answer below.  </p>
  
  <p><strong>Have:</strong> </p>
  
  <ul>
  <li>Interop.Word.dll ver.14 from VS2010 PIA, </li>
  <li>VS2010 Express Edition</li>
  <li>MS Word 2010 (ver.14) </li>
  <li>.docx-file made in mentioned Word manually without Interop. File contains several tables with colored corner cells.</li>
  </ul>
  
  <p><strong>Purpose:</strong>
  To build another .docx-file with Interop contained those tables filled with gradient color based on colors in its corners. <br>
  <strong>Where problem appears:</strong> I need to transform colors in tables corners from <code>WdColor</code> to <code>System.Drawing.Color</code> to calculate gradient. So I work with cell's <code>Shading.BackgroundPatternColor</code> property. And I found that sometimes it contains correct BGR 24-bit value and sometimes it doesn't. <br>
  The second case appears only when cell has one of the theme palette colors (standard and rgb-palette colors works well, but theme palette colors lead to problem). For example, when I set <code>0x00F2F2F2</code> (the lightest gray) color then it stores in <code>document.xml</code> inside .docx-file archive correctly but <code>Shading.BackgroundPatternColor</code> property is set to <code>0xDC00F2FF</code>. So <code>ColorTranslator.FromOle</code> returns different color. <br>
  Btw, there's no WdColor for this gray in enum. The lighest gray <code>wdColorGray05 = 0xF3F3F3</code> due to .Net Reflector. It means that not all palette default colors correspond to enum colors. <br>
  Also if I set manually the same color in RGB-palette in Word (ie. 242, 242, 242), save file and open again by Interop - color will be set properly as <code>0x00F2F2F2</code>! <br>
  <strong>Question:</strong> Anybody had that problem? How to properly retrieve RGB color from <code>Shading.BackgroundPatternColor</code> property? Why this property doesn't correspond to value stored in <code>document.xml</code>?</p>