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

(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
    WinHttpReq.Send

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

could some one suggest the changes.

Leave a Reply

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