ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Accessing Excel Documents on a SharePoint Site (https://www.excelbanter.com/excel-programming/425037-accessing-excel-documents-sharepoint-site.html)

ExcelMonkey

Accessing Excel Documents on a SharePoint Site
 
Can anyone tell me how to access Excel Documents on a SharePoint site using
VBA.


Thanks

EM

ExcelMonkey

Accessing Excel Documents on a SharePoint Site
 
I am trying to loop through my personal folder with the following code below.
The URL is what appears in the explorer bar when I go to my Personal folder
on the SharedPoint Site. However it fails on the line of code:

Set oFolder = oFSO.GetFolder(strPath)

What am I doing wrong?

Sub ListAllFilesInFolder()
Dim strPath As String
Dim oFSO As Object
Dim oFile As Object
Dim oFolder As Object
Dim N As Long
N = 1

strPath =
"http://mysite.cnpl.Aco.com/personal/username/Personal%20Documents/Forms/AllItems.aspx" '<<< CHANGE

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(strPath)
Cells(N, 1).Value = oFolder.Path
N = N + 1
For Each oFile In oFolder.Files
Cells(N, 2).Value = oFile.Name
N = N + 1
Next 'oFile

Set oFSO = Nothing
Set oFile = Nothing
Set oFolder = Nothing
End Sub

Thanks

EM

"ExcelMonkey" wrote:

Can anyone tell me how to access Excel Documents on a SharePoint site using
VBA.


Thanks

EM


XL_alstar

Loop through folder
 
This should work:
strPath =
"\\mysite.cnpl.Aco.com\personal\username\Personal% 20Documents"





All times are GMT +1. The time now is 11:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com