Hi all,
I am web scraping and I found this code which open IE on memory and extracts the information I need. However, I keep getting this message: "Run time error 429: ActiveX component can't create object". I tried changing the "Set IE = New InternetExplorer" to "Set IE = CreateObject("InternetExplorer.Application")" but still got the error.
I have referenced: Microsoft Internet Controls and Microsoft HTML Object Library.
I am using Windows 10.
Please find the code below.
Best Rgds.,
Exc4.
I am web scraping and I found this code which open IE on memory and extracts the information I need. However, I keep getting this message: "Run time error 429: ActiveX component can't create object". I tried changing the "Set IE = New InternetExplorer" to "Set IE = CreateObject("InternetExplorer.Application")" but still got the error.
I have referenced: Microsoft Internet Controls and Microsoft HTML Object Library.
I am using Windows 10.
Please find the code below.
Best Rgds.,
Exc4.
Code:
Enum READYSTATE
READYSTATE_UNINITIALIZED = 0
READYSTATE_LOADING = 1
READYSTATE_LOADED = 2
READYSTATE_INTERACTIVE = 3
READYSTATE_COMPLETE = 4
End Enum
Sub ImportStackOverflowData()
'Source: http://www.wiseowl.co.uk/blog/s393/scrape-website-html.htm
'to refer to the running copy of Internet Explorer
Dim ie As InternetExplorer
'to refer to the HTML document returned
Dim html As HTMLDocument
'open Internet Explorer in memory, and go to website
Set ie = New InternetExplorer
ie.Visible = False
ie.navigate "http://stackoverflow.com/"
'Wait until IE is done loading page
Do While ie.readyState <> READYSTATE_COMPLETE
Application.StatusBar = "Trying to go to StackOverflow ..."
DoEvents
Loop
'show text of HTML document returned
Set html = ie.document
MsgBox html.DocumentElement.innerHTML
'close down IE and reset status bar
Set ie = Nothing
Application.StatusBar = ""
End Sub