title: VBA: not able to pull value within <input> tag using getelementsbyTagname().Value
body: <p>This is my first post on stackflow :) I've been Googling VBA knowledge and writing some VBA for about a month. </p>
  
  <p><strong>My computer info:</strong></p>
  
  <p>1.window 8.1</p>
  
  <p>2.excel 2013</p>
  
  <p>3.ie 11</p>
  
  <p><strong>My excel reference</strong></p>
  
  <p>Microsoft Object Library: yes</p>
  
  <p>Microsoft Internet Controls: yes</p>
  
  <p>Microsoft Form 2.0 Object library: yes</p>
  
  <p>Microsoft Script Control 1.0: yes</p>
  
  <p><strong>Issue:</strong> </p>
  
  <p>I was trying to retrieve data from internet explorer automatically using VBA.
  I would like to retrieve the value within an input tag from a id called "u_0_1" which is under a id called "facebook". I am expecting to retrieve the value "AQFFmT0qn1TW" on cell c2. However, it got this msg popped up after I run the VBA "run-time error '91':object variable or with block variable not set.
  I have been trying this for a couple of weeks using different methods such as,</p>
  
  <p>1.getelementsbyClassname</p>
  
  <p>2.getelementbyid</p>
  
  <p>3.getelementsbyTagname</p>
  
  <p>But it just doesn't work.</p>
  
  <p><strong>url:</strong> </p>
  
  <p><a href="http://coursesweb.net/javascript/getelementsbytagname" rel="nofollow">http://coursesweb.net/javascript/getelementsbytagname</a></p>
  
  <p>Below is my VBA code. Could you guys help me out a little bit please?</p>
  
  <pre><code>Private Sub CommandButton1_Click()
  Dim ie As Object
  Dim Doc As HTMLDocument
  Dim getThis As String
  
  
  
  Set ie = CreateObject("InternetExplorer.Application")
  
      ie.Visible = 0
  
  
      ie.navigate "http://coursesweb.net/javascript/getelementsbytagname"
      Do
      DoEvents
      Loop Until ie.readyState = 4
  
  
  
      Set Doc = ie.document
  
  
      getThis = Trim(Doc.getElementById("u_0_1")(0).getElementsByTagName("input")(0).Value)
      Range("c2").Value = getThis
  End Sub            
  </code></pre>