我正试图通过VBA获取Excel,以访问网页:
http://www.nordea.dk/wemapp/currency/dk/valutaKurser?0
然后单击"12 M neder“,从下拉到右上角下载该表。
我使用querytable将复制/粘贴钉牢,但我无法让Excel单击按钮--这样我就可以得到正确的句号。
想法?
发布于 2015-07-07 11:32:43
如果您要求MS为您编写VBA代码(使用记录器),您将得到如下结果:
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.nordea.dk/wemapp/currency/dk/valutaKurser?0", Destination:= _
Range("$A$1"))
.Name = "valutaKurser?0"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
不确定是否可以在web查询中更改某些内容,但如果手动进行,则肯定可以这样做:(1)打开网站,(2)更改选项,(3)遍历这些项以获得它们的值。
Sub GetRates()
Set objIE = CreateObject("InternetExplorer.Application")
WebSite = "http://www.nordea.dk/wemapp/currency/dk/valutaKurser?0"
With objIE
.Visible = True
.navigate WebSite
Do While .Busy Or .readyState <> 4
DoEvents
Loop
Set Element = .document.all("fwRate")
Element.Value = 4 '=12 måneder
'iterarte through the elements to get the rates manually
End With
End Sub
https://stackoverflow.com/questions/31264841
复制相似问题