(Solved) – Download Dynamic Excel file from Sharepoint using VBA Code


I want to download Excel(.xlsx) file whose Naming convention is Dynamic, either in Quarter or Day.

I have a VBA Code to download but that works only on Static name ,

Below is the code:

Sub DownloadFromSharepoint()
    Dim myURL As String
    myURL = "https://****/projects/Facets-Mig/CentralVA Combined Documentation/Central Migrations Trackers/Central Migrations Master Tracker_Q42019.xlsx?Web=1"

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

    If WinHttpReq.Status = 200 Then
        Set oStream = CreateObject("ADODB.Stream")
        oStream.Type = 1
        oStream.Write WinHttpReq.ResponseBody
        oStream.SaveToFile ("C:Users****DesktopSharepoint DownloadCentral.xlsx")
    End If End Sub

could some one suggest the changes.

Leave a Reply

Your email address will not be published. Required fields are marked *