Question posted 2009 · +13 upvotes
Usually I use this piece of code to retrieve the content of a folder in VBA. But this doesn’t work in the case of a sharepoint. How can I do ?
Dim folder As folder
Dim f As File
Dim fs As New FileSystemObject
Set folder = fs.GetFolder("//sharepoint.address/path/to/folder")
For Each f In folder.Files
'Do something
Next f
EDIT (after a good comment by shahkalpesh) :
I can access to the sharepoint if I enter the address in Windows Explorer. Access to the sharepoint needs an authentification, but it’s transparent, because it relies on the Windows login.
Accepted answer +8 upvotes
In addition to:
myFilePath = replace(myFilePath, "/", "")
myFilePath = replace(myFilePath, "http:", "")
also replace space:
myFilePath = replace(myFilePath, " ", "%20")
2 code variants in this answer
- Variant 1 — 2 lines, starts with
myFilePath = replace(myFilePath, "/", "") - Variant 2 — 1 lines, starts with
myFilePath = replace(myFilePath, " ", "%20")
Top vba Q&A (6)
- Difference between Visual Basic 6.0 and VBA +122 (2009)
- VBA – how to conditionally skip a for loop iteration +116 (2011)
- VBA: Test if string begins with a string? +53 (2013)
- html parsing of cricinfo scorecards +47 (2012)
- Code to loop through all records in MS Access +46 (2011)
- Access VBA | How to replace parts of a string with another string +44 (2011)
vba solutions on this site
.