title: How to import background color from HTML to Excel with VBA Macro
body: <p>i try to get some information out of a table within a website by macro to an excel table. usually I just use </p>
  
  <pre><code>ie2.ExecWB 17, 0 '// SelectAll
  ie2.ExecWB 12, 2 '// Copy selection
  </code></pre>
  
  <p>and paste it to any excel sheet which is enough for my needs. but the website was changed. the problem is now, that I need to get the information of website cell with the following code:</p>
  
  <pre><code>&lt;tr class="odd"&gt;&lt;td&gt;&lt;a href="xxxxxxx"&gt;
  &lt;img border="0" src="letter.png" title="Titel0" /&gt;&lt;/a&gt;&lt;td&gt;&lt;/td&gt;
  &lt;td&gt;&lt;img title="VServer Usage" style="background-color:#00dd00" border="0" src="/ce.png" /&gt;&amp;nbsp;&lt;a   
  href="testtesttest"&gt;blablabla&lt;/a&gt;&lt;/td&gt;
  &lt;td&gt;&lt;a href="http://maps.google.de/" target="_blank"&gt;TEST TEST&lt;/a&gt;&lt;/td&gt;
  &lt;td&gt;&lt;img border="0" src="/damage.png" title="Titel1"/&gt;&lt;/a&gt;&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;img border="0" src="/card.png" title="Titel2"/&gt;&lt;/a&gt;&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;img border="0" src="/key.png" title="Titel3" /&gt;&lt;/a&gt;&lt;/td&gt;
  &lt;td&gt;&lt;img border="0" src="/immo.png" title="Titel4" /&gt;&lt;/a&gt;&lt;/td&gt;
  &lt;td&gt;&lt;img border="0" src="/locked.png" title="Titel5" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;101&lt;/td&gt;
  &lt;td&gt;102&lt;/td&gt;&lt;td&gt;103&lt;/td&gt;&lt;td&gt;104&lt;/td&gt;&lt;td&gt;105&lt;/td&gt;&lt;td&gt;106&lt;/td&gt;&lt;td&gt;107&lt;/td&gt;&lt;td&gt;Name&lt;/td&gt;
  &lt;/tr&gt;
  
  // and then it starts with the next line which has the same structure
  </code></pre>
  
  <p>by that code I need to get the value for the background color (which can be #00dd00 or #000000 or #ff0000 or #0000ff) and paste it to excel cell B5. then the macro need to get the background color value below the one before and paste it to the cell B6 (and so on and so on). </p>
  
  <p>any idea how to realize that?</p>
  
  <p>Here is my first Idea: I parse through the whole sourcecode, look for a certain string and copy the following charakters with that code:</p>
  
  <pre><code>Dim strCountBody As String
  Dim lStartPos As Long
  Dim lEndPos As Long
  Dim TextIWant As String
  Dim Textpos As Integer
  Dim searchchar As String
  
  searchchar = "VServer Usage" 
  
  
  Application.ScreenUpdating = False
  
  
  Set WebBrowser1 = CreateObject("InternetExplorer.Application")
  WebBrowser1.Visible = True ' zum testen anzeigen
  WebBrowser1.Navigate "wwww.www..www"
  While WebBrowser1.readyState &lt;&gt; 4
      'Warten, bis Seite geladen ist
      DoEvents
  Wend
  
  strCountBody = WebBrowser1.Document.body.innerHTML
  textpos = InStr(5500, strCountBody, searchchar, vbTextCompare)
  
  TextIWant = Mid(strCountBody, Textpos, 25)
  
  Worksheets("Tabelle1").Range("J1").Value = TextIWant
  Worksheets("Tabelle1").Range("K1").Value = Textpos
  </code></pre>
  
  <p>That seems to work. The positions are correct BUT the search result is only: VServer Usage" border="0", which means that the whole part</p>
  
  <pre><code>style="background-color:#00dd00"
  </code></pre>
  
  <p>is not found and ignored. I also tried it with:</p>
  
  <pre><code>WebBrowser1.Document.body.innerHTML
  WebBrowser1.Document.body.outerHTML
  WebBrowser1.Document.body.innerText
  WebBrowser1.Document.body.outerText
  </code></pre>
  
  <p>but all with the same result :(</p>