proceed changing in a webpage (or click something on that?)

trady

New Member
Joined
Apr 22, 2016
Messages
1
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:
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")
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!
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,214,909
Messages
6,122,189
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top