Sharepoint URL path works but not in VBA?

NessPJ

Active Member
Joined
May 10, 2011
Messages
431
Office Version
  1. 365
I have a few Excel tools that work without issue and i want to try and make them compatible with using the tool from a Sharepoint.
I copied the path to some of the files, from the Sharepoint (File -> Info -> Path) section but it still does not seem to work (i receive Error: Bad File Name or Number).
Is there some other type of pathing i should be using?

If i Debug.Print the source Filepaths i can just copy them into my browser and they work right away!

VBA Code:
  Dim Dag1 As String
             
    Dag1 = Range("AC9").Value
    
    If Not IsEmpty(Range("O9")) Then
       
    FileCopy "https://companyname.sharepoint.com/sites/155/SiteName/FolderName%20With%20Spaces/OtherFolder/1.1)%20AnotherFolder/Data/log.file." & Dag1 & ".csv", "https://companyname.sharepoint.com/sites/155/SiteName/FolderName%20With%20Spaces/OtherFolder/1.1)%20AnotherFolder/Data/Processed/Dag%201/log.file.processed.xls"
    
    End If
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Whenever I needed to work on a SP file through VBA I used the network address of the server, not the web address. The url you paste into a browser works because the browser serves up web pages from url or local hard drive. URL's do not work with hard drive/local network drives. If you can map a drive to the sp server you can right click on it in File Explorer and look at the property sheet. That will tell you what the network address is and its syntax is known as a UNC path. Or you could ask the network admin. It will begin with 2 slashes: \\ followed by what looks like the usual folder hierarchy.
 
Upvote 0
Try

.SaveAs YourNewFilePath
 
Upvote 0
Whenever I needed to work on a SP file through VBA I used the network address of the server, not the web address. The url you paste into a browser works because the browser serves up web pages from url or local hard drive. URL's do not work with hard drive/local network drives. If you can map a drive to the sp server you can right click on it in File Explorer and look at the property sheet. That will tell you what the network address is and its syntax is known as a UNC path. Or you could ask the network admin. It will begin with 2 slashes: \\ followed by what looks like the usual folder hierarchy.
I did not know, mapping to a network drive was actually possible for a Sharepoint location.
I will ask IT directly if they can do so.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

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