title: internetexplorer.application hangs on readystate=1 in VBA
body: <p>I have an Excel VBA application which uses internetexplorer.application to explore an application.  Starting around 2/21/15, this application started failing on readyState being stuck on 1 forever rather than ultimately migrating to 4.  This only occurred when navigating the second (or further) link.  The first URL works fine.</p>
  
  <p>The machine with the problem is a Core i5 M520 CPU (4 CPU) running 64-bit Windows 7.</p>
  
  <p>Another machine with a Core 2 Duo T9400 running 32-bit Windows 7 executes the code without a problem.</p>
  
  <p>This feels like some sort of race condition but I am not sure if I have to do something special under 64-bit windows.</p>
  
  <p>I am using Internet Explorer 11, Windows 7, and Excel 2003 (or 2013).  Any idea on what is going wrong?</p>
  
  <pre><code>Option Explicit
  
  Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  Dim objIE As Object
  Dim iNodeCount As Long
  Dim iLevel As Long
  Dim iMaxLevel As Long
  Dim iReadyStateLoopCount As Long
  
  '------------------------------------------------------
  '
  ' Main driver of the test case
  '
  '------------------------------------------------------
  
  Sub Test_IE_Interface()
  
      Set objIE = CreateObject("InternetExplorer.Application")
      With objIE
        .AddressBar = True
        .StatusBar = True
        .MenuBar = True
        .Toolbar = True
        .Visible = True
      End With
  
      LoadAPage "http://events.gotsport.com/events/Default.aspx?EventID=44163"
  
      '  This example generally hangs on the following call
  
      LoadAPage "http://events.gotsport.com/events/schedule.aspx?EventID=44163&amp;Gender=Boys&amp;Age=18"
      LoadAPage "http://events.gotsport.com/events/schedule.aspx?EventID=44163&amp;Gender=Boys&amp;Age=19"
      LoadAPage "http://events.gotsport.com/events/schedule.aspx?EventID=44163&amp;Gender=Boys&amp;Age=13"
      LoadAPage "http://events.gotsport.com/events/schedule.aspx?EventID=44163&amp;Gender=Boys&amp;Age=14"
      LoadAPage "http://events.gotsport.com/events/schedule.aspx?EventID=44163&amp;Gender=Boys&amp;Age=15"
      LoadAPage "http://events.gotsport.com/events/schedule.aspx?EventID=44163&amp;Gender=Boys&amp;Age=16"
      LoadAPage "http://events.gotsport.com/events/schedule.aspx?EventID=44163&amp;Gender=Boys&amp;Age=17"
  
      objIE.Quit
  End Sub
  
  '--------------------------------------------------------------
  '
  ' This routine loads a web page and then peruses the document
  '
  '--------------------------------------------------------------
  
  Sub LoadAPage(sURL As String)
      Dim sState As String
      Dim sNewURL As String
      Dim objDoc As Object
  
      objIE.navigate sURL
  
      Do While objIE.Busy
          DoEvents
          Sleep 10
          DoEvents
      Loop
  
      ' &gt;&gt;&gt; Getting stuck in the following loop in the second call &lt;&lt;&lt;
      ' &gt;&gt;&gt; OBJie.readyState is always 1 (READYSTATE_LOADING) &lt;&lt;&lt;
  
      Do While objIE.readyState &lt;&gt; 4   ' READYSTATE_COMPLETE = 4
          DoEvents
          Sleep 10
          DoEvents
          iReadyStateLoopCount = iReadyStateLoopCount + 1
      Loop
  
      Set objDoc = objIE.document
  
      sState = objDoc.readyState
      Do While sState &lt;&gt; "complete"
        DoEvents
        Sleep 10
        sState = objDoc.readyState
      Loop
  
      If objDoc.URL &lt;&gt; sURL Then
          MsgBox "The new URL was not loaded" &amp; vbCrLf &amp; _
                 "URL Requested: " &amp; sURL &amp; vbCrLf &amp; _
                 "URL Returned:  " &amp; objDoc.URL
      End If
  
      iNodeCount = 0
      iLevel = 0
      iMaxLevel = 0
  
      PeruseTheDocument objDoc
  
  End Sub
  
  '--------------------------------------------------
  '
  '  This is a dummy routine to examine the document
  '
  '--------------------------------------------------
  
  Sub PeruseTheDocument(objNode As Object)
      Dim objChild As Object
  
      iNodeCount = iNodeCount + 1
      iLevel = iLevel + 1
  
      If iLevel &gt; iMaxLevel Then
          iMaxLevel = iLevel
      End If
  
      If Not objNode Is Nothing Then
          If Not IsNull(objNode.FirstChild) Then
              Set objChild = objNode.FirstChild
              Do Until IsNull(objChild) Or objChild Is Nothing
  
                  ' Make this go faster by not examining all nodes in the document
  
                  If iLevel &lt; 5 Then
                      PeruseTheDocument objChild
                  End If
  
                  If IsNull(objChild.nextSibling) Then
                      Set objChild = Nothing
                  Else
                      Set objChild = objChild.nextSibling
                  End If
              Loop
          End If
      End If
  
      iLevel = iLevel - 1
  End Sub
  </code></pre>