title: Excel VB - getelementsbytagname - returns Run-time error '438'
body: <p>I'm a golfing enthusiast and a hobby programmer. I am attempting to write VB code that will grab a handicap from a website if passed a specific value (membership number). I have used a piece of code I found that appears to work well for their particular application, but the website I need to use appears to be slightly more complex.</p>
  
  <p>An excerpt of the webpage structure looks like the following:</p>
  
  <pre><code>&lt;div id="exactHandicap"&gt;
     &lt;h3&gt;G.A. Handicap&lt;/h3&gt;
     &lt;div id="handicapType"&gt;
         (Men's)
     &lt;/div&gt;
     &lt;br&gt;
     &lt;span&gt;
         &lt;span id="ContentPage_lblExactHandicap"&gt;26.9&lt;/span&gt;&lt;/span&gt;
     &lt;span id="AnchoredPanel"&gt;
     &lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I'm trying to simply grab the <strong>26.9</strong> value</p>
  
  <p>I've been searching for days as to how to reference it correctly with getelementsbytagname or getelementbyId but each return an error, the lastest being error '438'</p>
  
  <p>I am a HTML novice and this project has clearly identified that, but I'm sure that someone in this community has the answer.</p>
  
  <p>My code (borrowed from an online tutorial) is:</p>
  
  <pre><code>Private Sub Worksheet_Change(ByVal Target As Range)
  
    If Target.Row = Range("GolfLinkNumber").Row And _
    Target.Column = Range("GolfLinkNumber").Column Then
      Dim IE As New InternetExplorer
      IE.Visible = True
      IE.navigate "http://handicap.golflink.com.au/handicaphistory.asp?framed=1&amp;golflink_No=" &amp; Range("GolfLinkNumber").Value
      Do
      DoEvents
      Loop Until IE.readyState = READYSTATE_COMPLETE
  
      Dim Doc As HTMLDocument
      Set Doc = IE.Document
  
      Dim HandicapValue As String
  
      HandicapValue = Doc.getElementByTagName("ContentPage_lblExactHandicap").innervalue
      MsgBox HandicapValue
  
    End If
  
  End Sub
  </code></pre>
  
  <p>The error is at the...</p>
  
  <p><em>HandicapValue = Doc.getElementByTagName("ContentPage_lblExactHandicap").innervalue</em></p>
  
  <p>Thanks in advance.</p>