下载文件后,VBA在对话框提示框中单击“打开”

时间:2017-10-16 01:02:38

标签: excel vba internet-explorer

我想使用VBA通过URL下载文件。如何在不使用“sendkeys”命令的情况下单击“另存为”或“打开”?

到目前为止,这是我的代码:

Sub Orders_downloaden()
    Dim i As Long
    Dim ie As Object
    Dim objElement As Object
    Dim objCollection As Object

    ' Create InternetExplorer Object
    Set ie = CreateObject("InternetExplorer.Application")

    'IE.Visible = False

    ie.navigate "http://k2b-bulk.ebay.com/ws/eBayISAPI.dll?SMDownloadPickup"

    ' Wait while IE loading...
    Do While ie.Busy
        Application.Wait DateAdd("s", 1, Now)
    Loop

    ie.Visible = True

    Set link = ie.Document.getelementsbytagname("a")
    For Each l In link
    If l.innertext = "Download" Then
        l.Click
        Dim Report As Variant

        Report = Application.GetSaveAsFilename("Orders.csv", "Excel Files (*.csv), *.csv")
        'Shell ("C:\Program Files (x86)\Google\Chrome\Application\Chrome.exe -url " & l), vbHide
        Exit For
    End If
    Next l

End Sub

有人知道如何管理这个吗?

0 个答案:

没有答案