File Download - Excel - Firefox

0

I have the download link for an xls file. Every day I need to DOWNLOAD this file (I can only access through firefox), SAVE in a folder to feed my spreadsheet (the spreadsheet is "linked" in this file.) I need a macro to do: download this file (the link is ready) automatically to a folder.

    
asked by anonymous 07.05.2017 / 15:39

1 answer

0

Try using the following adapted function with your data:

Sub downloadFile()
    Dim myURL As String

    myURL = "http://portal.convenios.gov.br/images/docs/CGSIS/csv/siconv.zip" ' Coloque sua URL aqui!!!


    Dim WinHttpReq As Object
    Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
    WinHttpReq.Open "GET", myURL, False
    WinHttpReq.Send

    myURL = WinHttpReq.ResponseBody
    If WinHttpReq.Status = 200 Then
        Set oStream = CreateObject("ADODB.Stream")
        oStream.Open
        oStream.Type = 1
        oStream.Write WinHttpReq.ResponseBody
        oStream.SaveToFile ("C:\Users\user\Downloads\file.zip")
        oStream.Close
    End If
End Sub

Code adapted from:

link

    
08.05.2017 / 01:14