Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

download excel file from sharepoint

HI,

I want to download latest excel file from share point to local folder path using VBscript.

I have the VBscript code it is down loading current month file if it is present,that is this month file it is downloading if it present in share point but i want to download latest file upload in share point.

Ex: my file formate is :

10_2014 Filename.xlsx...etc..

if they uploaded 12_2014 Filename.xlsx file then i want to download this file.

i am using following code but it is downloading current month file:

Sub DownloadFile

'Identifying the latest Security file'

latestDate = Date

strYear = Year(latestDate)

strMonth = Right("0" & Month(latestDate), 2)

fileName = strMonth&"_"&strYear&" Filename.xlsx"

'strMonth&"_"&strYear&" Filename.xlsx"'

SharePointURL = "http://sharepointpath"

Current Month Data Load File/"&fileName

Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")

WinHttpReq.Open "GET", SharePointURL, False, "username", "password"

WinHttpReq.send

SharePointURL = WinHttpReq.responseBody

If WinHttpReq.Status = 200 Then

    Set oStream = CreateObject("ADODB.Stream")

    oStream.Open

    oStream.Type = 1

    oStream.Write WinHttpReq.responseBody

    oStream.SaveToFile "folderpath\"&fileName, 1 ' 1 = no overwrite, 2 = overwrite

    oStream.Close

End If

End Sub

0 Replies