title: Excel VBA to populate I.E. causes Run-time error in I.E. 11 but not 9
body: <p>I created a sub to populate form fields in a website with data from an Excel workbook</p>
  
  <p>The sub opens a new window in Internet Explorer, navigates to a intranet site, and populates form fields with data from an Excel workbook</p>
  
  <p>This sub works using Win7 Excel 2010 and I.E. 9</p>
  
  <p>When I use newer versions of I.E., the sub opens a new window in Internet Explorer and navigates to a intranet site, but fails to populate the form fields
  I receive the following error from VBA:</p>
  
  <p><strong><em>Run-time error ‘-2147417848 (80010108)’:</em></strong></p>
  
  <p><strong><em>Automation error</em></strong></p>
  
  <p><strong><em>The object invoked has disconnected from its clients</em></strong></p>
  
  <p>Here is my code</p>
  
  <pre><code>Sub hOpenWsAndPopulate()
  Dim ie      As Object
  Dim frm     As Variant
  Dim element As Variant
  
  Set ie = CreateObject("InternetExplorer.Application")
  ie.navigate "www.mywebsite.com"
  While ie.readyState &lt;&gt; 4: DoEvents: Wend
  
  ' try to get form by ID
  Set frm = ie.document.getElementById("incidentTicket_Form")
  
  ' try to get form by tag name and index.
  ' Item(0) = 1st form
  ' Item(1) = 2nd form
  ' Item(2) = 3rd form, etc.
  If frm Is Nothing Then Set frm = ie.document.getElementsByTagName("form").Item(0)
  
  If frm Is Nothing Then
      MsgBox "Form not found"
      ie.Quit
      Set ie = Nothing
      Else
          ie.Visible = True
          For Each element In frm.elements
              On Error Resume Next
              Select Case element.Name
                  ' Input Classification
                      Case "strClassificationName": element.Value = Sheets("OUT-Class").Range("Classification")
                  ' Input Short Description
                      Case "txtShortDescription": element.Value = Sheets("OUT-SD").Range("SD_Output")
                  ' Input Long Description
                      Case "txtLongDescription": element.Value = Sheets("OUT-LD").Range("LD_Output")
                  ' Input CC
                      Case "strCCString": element.Value = Sheets("OUT-CC").Range("CcBa")
              End Select
      Next
  End If
  End Sub
  </code></pre>
  
  <p>I've tried numerous changes to my code (below), but nothing works</p>
  
  <pre><code>Sub zzzOpenWsAndPopulate()
  
  Dim objIE As InternetExplorer
  Dim htmlDoc As HTMLDocument
  Dim htmlFrame As HTMLFrameElement
  Dim frame As HTMLIFrame
  Dim htmlElement As HTMLDTElement
  Dim myDoc As Object
  Dim frm     As Variant
  Dim element As Variant
  
  
  ' Set the variables
  Set objIE = New InternetExplorer
  
  ' Make the browser visible and navigate
  With objIE
      .Visible = True
      .navigate "www.mywebsite.com"
  End With
  
  hWaitForInternetToLoad objIE
  
  Set frm = objIE.document.getElementById("incidentTicket_Form")
  
  If frm Is Nothing Then Set frm = ie.document.getElementsByTagName("form").Item(0)
  
  If frm Is Nothing Then
      MsgBox "Form not found"
      ie.Quit
      Set ie = Nothing
      Else
          objIE.Visible = True
          For Each element In frm.elements
              On Error Resume Next
              Select Case element.Name
                  ' Input Classification
                      Case "strClassificationName": element.Value = Sheets("OUT-Class").Range("Classification")
                  ' Input Short Description
                      Case "txtShortDescription": element.Value = Sheets("OUT-SD").Range("SD_Output")
                  ' Input Long Description
                      Case "txtLongDescription": element.Value = Sheets("OUT-LD").Range("LD_Output")
                  ' Input CC
                      Case "strCCString": element.Value = Sheets("OUT-CC").Range("CcBa")
              End Select
      Next
  End If
  
  
  End Sub
  </code></pre>
  
  <p>Is there something about I.E. 10, 11, etc. that is different from I.E. 9?</p>
  
  <p>Is there a way to force open an older version of I.E. (browser mode 9)</p>
  
  <p>Any suggestions?</p>