title: Copy data from HTML
body: <p>I am trying to learn how to parse data from HTML using Excel VBA. So I found one example online which works fine but when I change URL address from <code>www.yahoo.com</code> to local HTML file on C it gives me error i.e. <em>Method 'busy' of object 'IwebBrowser2' failed.</em> Code is:</p>
  
  <pre><code>Sub GetBodyText()
  
  Dim URL As String
  Dim Data As String
  
  URL = "file:///C:/test.html"
  
  Dim ie As Object
  Dim ieDoc As Object
  
  Set ie = CreateObject("InternetExplorer.Application")
  ie.navigate URL
  
  Do Until (ie.readyState = 4 And Not ie.Busy)
      DoEvents
  Loop
  
  Set ieDoc = ie.Document
  
  Data = ieDoc.body.innerText
  
  'Split Data into separate lines
  'or just use Range("A1")=data
  Dim myarray As Variant
  myarray = Split(Data, vbCrLf)
  
  For i = 0 To UBound(myarray)
      'Start writing in cell A1
      Cells(i + 1, 1) = myarray(i)
  Next
  
  
  ie.Quit
  Set ie = Nothing
  Set ieDoc = Nothing
  
  End Sub
  </code></pre>