0

I am trying to get access the share point folder and files using VBA.

I have tried the same code to access the local folders and files it was working perfectly fine.

Here is my folder structure from share point. I need to access all the files inside the folder

Mainfolder
   Folder 1
   Folder 2
   Folder 3
   Folder 4 

Option Explicit

Sub Somesub()

Call GetFiles("https://isharenew.xyz.com/main folder \")
 End Sub

Sub GetFiles(ByVal path As String)
   Dim spSite As String
   Dim fso As Object
   Set fso = CreateObject("Scripting.FileSystemObject")

   Dim folder As Object
   Set folder = fso.GetFolder(path)

   Dim subfolder As Object
   Dim file As Object

   For Each subfolder In folder.SubFolders
      GetFiles (subfolder.path)
   Next subfolder

   For Each file In folder.Files
      Range("L" & Rows.Count).End(xlUp).Offset(1, 0) = file.path
   Next file

  Set fso = Nothing
  Set folder = Nothing
  Set subfolder = Nothing
  Set file = Nothing

   End Sub

With my above code I am getting error Path Not Found

Please let me know where I am doing mistake.

Mr.M
  • 1,472
  • 3
  • 29
  • 76
  • SharePoint is not a file system. You can't access it with FSO. You need to transform the URL into a WebDAV address. See here https://stackoverflow.com/questions/19505513/open-an-excel-file-from-sharepoint-site - the answer given by Shrout1 – teylyn Aug 16 '19 at 04:46
  • Thanks for pointing the question is that possible can you please help me in adopt that answer with my code I was trying but not coming – Mr.M Aug 16 '19 at 05:40

0 Answers0