Reads HTML source page of a webpage, maynot work for heavy js pages, but works in general everywhere.
Just like Navigate but using IE reference.
Make sure you include two references as shown in screenshot.
Function Navigate_IE(ForURL)
' Needs reference to IE inside VBE
'
'Enum READYSTATE
' READYSTATE_UNINITIALIZED = 0
' READYSTATE_LOADING = 1
' READYSTATE_LOADED = 2
' READYSTATE_INTERACTIVE = 3
' READYSTATE_COMPLETE = 4
'End Enum
'
Dim ie As InternetExplorer 'to refer to the running copy of Internet Explorer
Dim html As HTMLDocument 'to refer to the HTML document returned
Set ie = New InternetExplorer 'open Internet Explorer in memory, and go to website
ie.Visible = False
ie.Navigate ForURL '"http://stackoverflow.com/"
Do While ie.READYSTATE < > 4 'Wait until IE is done loading page
' Application.StatusBar = "Trying to go to StackOverflow ..."
DoEvents
Loop
Set html = ie.document 'show text of HTML document returned
Navigate_IE = html.DocumentElement.innerHTML
Set ie = Nothing 'close down IE and reset status bar
Set html = Nothing
' Application.StatusBar = ""
End Function
' Needs reference to IE inside VBE
'
'Enum READYSTATE
' READYSTATE_UNINITIALIZED = 0
' READYSTATE_LOADING = 1
' READYSTATE_LOADED = 2
' READYSTATE_INTERACTIVE = 3
' READYSTATE_COMPLETE = 4
'End Enum
'
Dim ie As InternetExplorer 'to refer to the running copy of Internet Explorer
Dim html As HTMLDocument 'to refer to the HTML document returned
Set ie = New InternetExplorer 'open Internet Explorer in memory, and go to website
ie.Visible = False
ie.Navigate ForURL '"http://stackoverflow.com/"
Do While ie.READYSTATE < > 4 'Wait until IE is done loading page
' Application.StatusBar = "Trying to go to StackOverflow ..."
DoEvents
Loop
Set html = ie.document 'show text of HTML document returned
Navigate_IE = html.DocumentElement.innerHTML
Set ie = Nothing 'close down IE and reset status bar
Set html = Nothing
' Application.StatusBar = ""
End Function
ForURL
Views 452
Downloads 147
CodeID
DB ID