单击列表,并将数据提取到 sheet

Click on list, and extract data to sheet

我正在尝试通过 VBA 获取 Excel 以访问网页:

http://www.nordea.dk/wemapp/currency/dk/valutaKurser?0

然后单击“12 måneder”,从右上角的下拉列表中下载 table。

我通过查询 table 确定了 copy/and 粘贴,但我无法 Excel 单击按钮 - 这样我就得到了正确的期间。

想法?

如果您要求 MS Excel 为您编写 VBA 代码(使用记录器),您将得到以下结果:

With ActiveSheet.QueryTables.Add(Connection:= _
    "URL;http://www.nordea.dk/wemapp/currency/dk/valutaKurser?0", Destination:= _
    Range("$A"))
    .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

不确定您是否可以在网络查询中更改某些内容,但如果您手动更改,则肯定可以这样做:(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