title: How to get innerText of an element by referencing its id?
body: <p>Code Masters!</p>
  
  <p>Newbie here! I was trying to create a tool for scraping texts from a website using .innerText method by referencing elements by its id, but with some ids I only get spaces and/or breaks.</p>
  
  <p>Here's the webpage's source code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="empName"&gt;
    &lt;h2&gt;Employee Name&lt;/h2&gt;
    &lt;div class="clear"&gt;&lt;/div&gt;
    &lt;span style="font-family:Arial; font-weight:bold"&gt;
      &lt;div id="empID"&gt;Employee ID&lt;/div&gt;
    &lt;/span&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Here's my VBA code:</p>
  
  <pre><code>Option Explicit
  
  Sub SampleCode()
  
  Dim IE As New SHDocVw.InternetExplorer
  Dim HTMLDoc As MSHTML.IHTMLDocument
  Dim EmployeeName As MSHTML.IHTMLElement
  Dim EmployeeID As MSHTML.IHTMLElement
  Dim URL As String
  
  URL = "www.example"
  
  With IE
      .Visible = True
      .FullScreen = True
      .Navigate URL
  End With
  
  Do
  Loop Until IE.ReadyState = READYSTATE_COMPLETE And IE.Busy &lt;&gt; True
  
  Set HTMLDoc = IE.Document
  Set EmployeeName = HTMLDoc.getElementById("empName")
  Set EmployeeID = HTMLDoc.getElementById("empID")
  
  Debug.Print EmployeeName.tagName, EmployeeName.innerText, EmployeeID.tagName, EmployeeID.innerText
  
  IE.FullScreen = False
  IE.Quit
  Set IE = Nothing
  
  End Sub
  </code></pre>
  
  <p>Here's the result as shown from Immediate Window:</p>
  
  <pre><code>DIV           Employee Name           DIV           
  </code></pre>
  
  <p>I followed tutorials from YouTube but I couldn't get the text from "empID" id attribute. Any suggestion will be much appreciated.</p>