forked from farishadi/Excel_Macro_References
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSharePointLoopThroughFilesInFolder
More file actions
27 lines (19 loc) · 919 Bytes
/
SharePointLoopThroughFilesInFolder
File metadata and controls
27 lines (19 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'This sub loops through the files in a specified sharepoint folder.
'The folder address must be in the format specified otherwise VBA doesn't really like that.
Sub SharePointLoopThroughFilesInFolder()
Dim sSPPath As String
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
'point to sharepoint folder that contains the files
'sharepoint path needs to be converted from "https://sharepoint drive/folder/another folder/another folder" to "//sharepoint drive/folder/another folder/another folder"
sSPPath = "//sharepoint drive/folder/another folder/another folder"
'create File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Use FSO object to get the folder pointed at by the directory
Set objFolder = objFSO.GetFolder(sSPPath)
'Loop through the files within the folder specified to get attributes
For Each objFile In objFolder.Files
a = objFile.Name
Next
End Sub