首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >单击“列表”,将数据提取到工作表中。

单击“列表”,将数据提取到工作表中。
EN

Stack Overflow用户
提问于 2015-07-07 09:31:09
回答 1查看 46关注 0票数 0

我正试图通过VBA获取Excel,以访问网页:

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

然后单击"12 M neder“,从下拉到右上角下载该表。

我使用querytable将复制/粘贴钉牢,但我无法让Excel单击按钮--这样我就可以得到正确的句号。

想法?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-07 11:32:43

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

代码语言:javascript
运行
复制
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)遍历这些项以获得它们的值。

代码语言:javascript
运行
复制
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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31264841

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档