This one is driving me crazy. I need to pass the entire HTML source for the URL below to a string variable using Excel VBA. The idea is that I will then parse the resulting string variable to pull out the data I require.
http://quote.morningstar.com/Option/...spx?ticker=EEM
The code I have attempted to use is shown below (also tried using other methods based around .innerhtml - all with same result). This does put some HTML source into the string variable - but it does not capture the full HTML source code that I see when right-clicking on the website and selecting 'view page source'.
In particular, it does not appear to contain the source code for any of the tables which appear on the page - the very same tables I need to pull out figures from. It is very odd, parts of the HTML within the returned string do not even seem to appear in the source code when I right click on the webpage.
All help greatly appreciated.
Many thanks!
Public objIE As Object
Sub GetHTMLSource()
Dim htmlsource as string
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.Visible = True
.navigate "http://quote.morningstar.com/Option/Options.aspx?ticker=EEM"
Do While .Busy Or _
.Readystate <> 4
DoEvents
Loop
htmlsource = .document.body.innerhtml
End with
End Sub
Bookmarks