Download file explicitly from sharepoint

Hi Team,
How can we download files explicitly from sharepoint as there is no direct mapping to sharepoint.
Please suggest.

Regards
Somya

There are Office 365 activities if you are using SharePoint online. If not, there are several option over on connect.uipath. Also, if you are using an MS office app such as excel, you can open directly (usually) by entering the URL. I’ve also done this by click/type into activities through the SharePoint site using the browser.

Hi @som17

Can you check this post. This might help you.

Thanks
Latika

Then you can simply use urlmon code (as long as you are running on Windows based machine).

Code:

Option Explicit

#If Win64 Then
  Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" Alias _
          "URLDownloadToFileA" ( _
          ByVal pCaller As LongLong, _
          ByVal szURL As String, _
          ByVal szFileName As String, _
          ByVal dwReserved As LongLong, _
          ByVal lpfnCB As LongLong) As LongLong
#Else
  Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
          "URLDownloadToFileA" ( _
          ByVal pCaller As Long, _
          ByVal szURL As String, _
          ByVal szFileName As String, _
          ByVal dwReserved As Long, _
          ByVal lpfnCB As Long) As Long
#End If


Function DownloadFile(Url As String, SavePathName As String) As Boolean
    DownloadFile = URLDownloadToFile(0, Replace(Url, "\", "/"), SavePathName, 0, 0) = 0
End Function

You can then use it like…

Code:

Sub Demo()
Dim strUrl As String, strSavePath As String, strFile As String
strUrl = "https://company.sharepoint.com/personal/User_domain_com/Documents/file.xlsx" 'SharePoint Path for the file
strSavePath = "C:\Test\" 'Folder to save the file
strFile = "FileName" & Format(Date, "dd.mm.yyyy") & ".xlsx"

If DownloadFile(strUrl, strSavePath & strFile) Then
    MsgBox "File saved to: " & vbNewLine & strSavePath
Else
    MsgBox "Unable to downloaf file:" & vbNewLine & strFile & vbNewLine & "Check url string and that document is shared", vbCritical
End If
End Sub

You can also try these simple steps-
Drag the SharePoint action and select “Create Session” activity.
Drag the SharePoint action and select the “ Download file ” activity.
Drag the SharePoint action and select “End session” activity.
I hope this will be helpful.
Best regards

can u pls help on this as well:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.