title: Get Element by ID from inside an iframe
body: <p>I'm trying to copy the last price of share prices into an Excel worksheet from</p>
  
  <p><code>&lt;div id="last-price-value" vkey="LastPrice"&gt;127.36&lt;/div&gt;.</code></p>
  
  <p>Internet Explorer opens and navigates to the site but the last price isn't copied to my worksheet. I added <code>Debug.Print</code> element.innertext but nothing appears in the immediate pane. </p>
  
  <pre><code>Dim element As IHTMLElement
  Dim elements As IHTMLElementCollection
  
  Dim ie As New InternetExplorer
  Dim html As HTMLDocument
  
  my_page = "http://www.morningstar.com/stocks/XASX/COH/quote.html"
  
  With ie
      .Visible = TRUE
      .Navigate my_page
  
      Do While ie.readyState &lt;&gt; READYSTATE_COMPLETE
      Loop
  
      Set html = ie.document
      Set element = html.getElementById("last-price-value")    
      Debug.Print element.innertext
  
      Sheets("Sheet 1").Range("A2").Value = element.innertext     
  End With
  </code></pre>