title: Getting the html "id" tag in excel vba
body: <p>I am working on a UPS tracking macro and I basically used the code from: <a href="https://stackoverflow.com/questions/22820892/vba-excel-ups-automated-tracking-clicking-a-button">UPS Automated tracking clicking a button</a>.</p>
  
  <p>However, I cannot seem to extract the status of the shipment after I manipulate the code to my liking. Below is what I have and the error that I am currently running into. </p>
  
  <blockquote>
    <p>Run-time error '91':
    Object variable or With block variable not set</p>
  </blockquote>
  
  <p>Code:</p>
  
  <pre><code>Sub test()
  ' open IE, navigate to the website of interest and loop until fully loaded
      Set ie = CreateObject("InternetExplorer.Application")
      my_url = "http://wwwapps.ups.com/WebTracking/track?loc=en_US"
  
      With ie
          .Visible = False
          .navigate my_url
          .Top = 50
          .Left = 530
          .Height = 400
          .Width = 400
  
      Do Until Not ie.Busy And ie.readyState = 4
          DoEvents
      Loop
  
      End With
  
  ' Enter a value in the "Number" text box
      ie.document.getElementById("trackNums").Value = "1Z12345E1512345676"
  
  ' Click the "Submit" button
      Set Results = ie.document.getElementsByTagName("input")
      For Each itm In Results
          If InStr(1, itm.outerhtml, "Track", vbTextCompare) &gt; 0 Then
              itm.Click
              Exit For
          End If
      Next
  
  ' Click the "Shipment Progress" button
      Set Results = ie.document.getElementsByTagName("input")
      For Each itm In Results
          If InStr(1, itm.outerhtml, "Shipment Progress", vbTextCompare) &gt; 0 Then
             itm.Click
             Exit For
          End If
      Next
  
  ' Get the text from the "Shipment Progress Table" and assign to a variable
      Dim status As String
  
      Set doc = ie.document
  
      Do While ie.Busy Or ie.readyState &lt;&gt; 4
          DoEvents
      Loop
      'tbltxt = doc.getElementsByTagName("pkgstep1").innerText
      status = doc.getElementById("tt_spStatus").innerText
  
      ' process the text as desired
      ActiveCell.Value = status
  
  End Sub
  </code></pre>
  
  <p>This exact line that I am running into problems is:</p>
  
  <pre><code>status = doc.getElementById("tt_spStatus").innerText
  </code></pre>
  
  <p>Here is the screenshot of the <code>text</code> I want to pull from the tag.
  <a href="https://i.stack.imgur.com/kW8sD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kW8sD.png" alt="tag"></a></p>