Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88111

Copy data from HTML

$
0
0

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 www.yahoo.com to local HTML file on C it gives me error i.e. Method 'busy' of object 'IwebBrowser2' failed. Code is:

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

Viewing all articles
Browse latest Browse all 88111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>