Im trying to use VBA to populate a spreadsheet with information about exdividend dates from a website.
The website has a default of 25 companies listed in the table, with which there is a drop down menu to select 15,25,50 or ALL. ALL is the option I am after. I cant get any .selected=4 to work.
I have the section of code working to retrieve the table and populate the cells, however currently i am only getting the first 25 companies (not enough, I need ALL of them!). Ive played around and searched in the forums for a solutions but none are working for me.
This is what i currently have
The structure for the html page is below
The value for the ALL option changes so i have to select the 4th option i cant use .value = "294"
The website has a default of 25 companies listed in the table, with which there is a drop down menu to select 15,25,50 or ALL. ALL is the option I am after. I cant get any .selected=4 to work.
I have the section of code working to retrieve the table and populate the cells, however currently i am only getting the first 25 companies (not enough, I need ALL of them!). Ive played around and searched in the forums for a solutions but none are working for me.
This is what i currently have
Code:
Dim HTMLDoc As New HTMLDocument
Dim elem As Object
Dim objIE As InternetExplorer
Set objIE = New InternetExplorer
objIE.navigate "https://www.morningstar.com.au/Stocks/UpcomingDividends"
Do Until objIE.readyState = 4 And Not objIE.Busy
DoEvents
Loop
Application.Wait (Now + TimeValue("0:00:03")) 'wait for java script to load
HTMLDoc.body.innerHTML = objIE.document.body.innerHTML
HTMLDoc.getElementTagName("select").selectedIndex = 4 'here is where it goes sour
HTMLDoc.getElementTagName("select").FireEvent ("onchange") 'error 438 ^
objIE.Quit
The structure for the html page is below
Code:
<div id="pager" class="pager">
<form>
<img src="/Content/scripts/tablesorter/addons/pager/icons/first.png" class="first"/>
<img src="/Content/scripts/tablesorter/addons/pager/icons/prev.png" class="prev"/>
<input type="text" class="pagedisplay"/>
<img src="/Content/scripts/tablesorter/addons/pager/icons/next.png" class="next"/>
<img src="/Content/scripts/tablesorter/addons/pager/icons/last.png" class="last"/>
<select class="pagesize">
<option value="15">15</option>
<option selected="selected" value="25">25</option>
<option value="50">50</option>
<option value="294">ALL</option>
</select>
</form>
</div>
The value for the ALL option changes so i have to select the 4th option i cant use .value = "294"