Copy a file from SharePoint into local folder using Excel VBA

Cakz Primz

Board Regular
Joined
Dec 4, 2016
Messages
102
Office Version
  1. 365
Platform
  1. Windows
Dear All,

I need to copy an Excel workbook from SharePoint into my local C drive, is it possible to do it with macro?
I have access and authorized to SharePoint, and I am using MS Office 365. I can copy/download manually from SharePoint.
I can even save my active Excel workbook using VBA to SharePoint, it means that I have no issue in authorization.

And I found this below code from Google, it gave me no error message/debug, but no file is being copied.

VBA Code:
Sub DownloadFromSharepoint()
    Dim SharepointAddress As String
    Dim LocalAddress As String
    Dim FS As Object

    SharepointAddress = "https://saipem.sharepoint.com/sites/dashboardtangguhlng/Shared Documents/PAMF/PROJECT_AGREEMENT_MANAGEMENT_FORM & REGISTER_Updated T&C.xlsx"
    LocalAddress = "C:\PROJECT_AGREEMENT_MANAGEMENT_FORM & REGISTER_Updated T&C.xlsx"
    Set FS = CreateObject("Scripting.FileSystemObject")
    If FS.FileExists(SharepointAddress) Then
    FS.CopyFile SharepointAddress, LocalAddress
    End If
End Sub

Even when I try this code below, no messagebox appear.

VBA Code:
Sub DownloadFromSharepoint()
    Dim SharepointAddress As String
    Dim LocalAddress As String
    Dim FS As Object

    SharepointAddress = "https://saipem.sharepoint.com/sites/dashboardtangguhlng/Shared Documents/PAMF/Purchase Order.xlsx"
    LocalAddress = "C:\"
    Set FS = CreateObject("Scripting.FileSystemObject")
    If FS.FileExists(SharepointAddress) Then
    MessageBox "File Exist"
    End If
End Sub

Really appreciate if somebody could help me and assist me.
Thank so much in advance.

prima - Indonesia
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
You can easily and automatically copy your files from Sharpoint to local using Gs Richcopy 360 or GoodSync, you can try the trial versions first
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,242
Members
452,623
Latest member
russelllowellpercy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top