I am new here, so forgive me if any information not specific.
I got a task to download data from this webpage using VBA: STOXX 600 Historical Rates - Investing.com
I want to have monthly, 5-year data, whereas the default values for the webpage are: daily and for 1-month. I can manipulate it by click the draw down menu and select "Monthly", and click several times on calendar controls, and below will show monthly, 5-yr data.
I tried many methods to change the "Time frame" and "Time period" by VBA code, but none of them work.
To change the time frame, I tried such methods:
But all of these changed the display on the time frame draw down menu, but not the data.
For the calendar, I have tried:
Some of these change the display of the calendar, but still none works.
There is no id called "startDate" or "endDate" when first time open the webpage. Only exist once you click the calendar control.
I even tried
as I noticed there is function embedded in the webpage, but the code got error.
It involves whole bunch of html code in the webpage, so I did not copy it here. Or do I have to?
I have also noticed that if the time frame displays "Monthly" (no matter whether it changes the data or not), and then click the calendar control to change the time period, the data will be shown as monthly. So maybe I only need to deal with the calendar?
It probably not easy, but I still want it to be worked out...
Thanks in advance for those who may want to solve it!
I got a task to download data from this webpage using VBA: STOXX 600 Historical Rates - Investing.com
I want to have monthly, 5-year data, whereas the default values for the webpage are: daily and for 1-month. I can manipulate it by click the draw down menu and select "Monthly", and click several times on calendar controls, and below will show monthly, 5-yr data.
I tried many methods to change the "Time frame" and "Time period" by VBA code, but none of them work.
To change the time frame, I tried such methods:
Code:
Dim ie As InternetExplorerDim html As HTMLDocument
Set ie = New InternetExplorer
ie.Visible = True
ie.navigate "http://www.investing.com/indices/stoxx-600-historical-data"
Set html = ie.document
Dim Selected As IHTMLElement
Code:
html.getElementsByTagName("select")("data_interval").Children(0).removeAttribute("selected") = Truehtml.getElementsByTagName("select")("data_interval").Children(2).setAttribute("selected", "").submit
html.getElementsByTagName("select")("data_interval").Value = "Monthly"
'Set Selected = html.getElementById("data_interval")
'Selected.FireEvent ("Click")
'Selected.Options.selectedIndex = 2
But all of these changed the display on the time frame draw down menu, but not the data.
For the calendar, I have tried:
Code:
html.getElementById("widgetFieldDateRange").innerText = "04/22/2011 - 04/22/2016"
html.getElementById("startDate").Text = "01/01/2011"
html.getElementById("endDate").Text = "01/01/2016"
html.getElementsByid("datePickerIconWrap").Click
html.getElementById("widget").Click
Some of these change the display of the calendar, but still none works.
There is no id called "startDate" or "endDate" when first time open the webpage. Only exist once you click the calendar control.
I even tried
Code:
Call html.parentWindow.execScript("historical_submit(False)", "JavaScript")
It involves whole bunch of html code in the webpage, so I did not copy it here. Or do I have to?
I have also noticed that if the time frame displays "Monthly" (no matter whether it changes the data or not), and then click the calendar control to change the time period, the data will be shown as monthly. So maybe I only need to deal with the calendar?
It probably not easy, but I still want it to be worked out...
Thanks in advance for those who may want to solve it!