我想通过VBA获取Excel,转到网页:
http://www.nordea.dk/wemapp/currency/dk/valutaKurser?0
然后点击“12måneder”,从下拉到右上角并下载表格。
我通过使用查询表得到了复制/粘贴,但是我无法让Excel点击按钮 - 这样我得到了正确的句号。
想法?
答案 0 :(得分:1)
如果您要求MS Excel为您编写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