【发布时间】:2015-09-15 10:17:29
【问题描述】:
我使用的网站是 www.msci.com。该网站使用了几种可以更改的表格。每个选择组合都会创建一个特定的值矩阵(所需的数据)。我想在我的 excel 工作表中创建相同的变量,这样我只需在工作表的 B 列中填写一些代码即可创建一个数据表,该数据表应放置在同一张工作表的其他位置。
我想我必须在我的宏中加入一些 html 代码来填充这些向下滚动的菜单(表单)。我发现了表单中的每个选项的 html ID,并尝试将它们合并到我的代码中。我认为代码部分有效,但是从日历模板更改日期肯定不起作用。到目前为止我的代码:
Sub getMSCIdata()
Dim mktval As String
Dim curr As String
Dim indlvl As String
Dim calendarinput As String
curr = Range("$B$3")
mktval = Range("$B$2")
indlvl = Range("$B$4")
calendarinput = Range("$B$5")
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.mscibarra.com/webapp/indexperf/pages/IEIPerformanceRegional.jsf?scope=0&mktval&size=36&style=C&calendarinput&curr&indlvl&lang=en" _
, Destination:=Range("$A$10"))
.Name = _
"IEIPerformanceRegional.jsf?scope=0&mktval&size=36&style=C&calendarinput&curr&indlvl&lang=en"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = """templateForm:tableResult0"""
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = True
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
【问题讨论】: