我想使用excel vba来控制Internet Explorer对象。
我们可以手动设置“https://www.investing.com/indices/us-30-historical-data”
如何使用excel vba执行此操作?
我有这段代码打开网址
('#s).jsTree({ ... , 'check_callback' });
但我不知道如何通过
有人可以帮忙吗?
答案 0 :(得分:0)
我想出了这个简单的宏(Excel 2010)来导航到坐下并更改日期和数据间隔,希望它会有所帮助:
Sub test()
Dim IE As InternetExplorer
Dim IEdoc As Object
Dim IEElement As Object
Set IE = New InternetExplorer 'initialize Internet Explorer
IE.Navigate "https://www.investing.com/indices/us-30-historical-data" 'Navigate to URL
IE.Visible = True
Set IEdoc = IE.Document
Set IEElement = IEdoc.GEtelementbyID("picker") ' navigate to date input
IEElement.Value = "01/01/2016 - 01/01/2017"
Set IEElement = IEdoc.GEtelementbyID("widget") ' navigate to date widget
IEElement.Click
Set IEElement = IEdoc.GEtelementbyID("applyBtn") ' navigate to Apply button to save the dates
IEElement.Click
Set IEElement = IEdoc.GEtelementbyID("data_interval") ' navigate to Interval picker
IEElement.Value = "Daily"
End Sub