Hi Folks,
Does anybody have some VBA code that checks if a file exists in Sharepoint?
I thought this would be a simple task but it's proving to be quite a challenge.
Hi Folks,
Does anybody have some VBA code that checks if a file exists in Sharepoint?
I thought this would be a simple task but it's proving to be quite a challenge.
Select "Add Reputation" to thank me.
Do you mean that you have just a filename, but you don't know where it's located, and you want to search for it? Or do you mean that you have a file name and location and want to see if it is actually there?
SharePoint is basically a web site and VBA does not have built-in features to search a web site. There may be an add-in or something available if you need to search.
Jeff
| | |·| |·| |·| |·| | |:| | |·| |·|
Read the rules
Use code tags to [code]enclose your code![/code]
I have a file name and location and want to ascertain if the file exists.
You should go with power query
This will check if a file exists at a specific URL:
![]()
Please Login or Register to view this content.
Many thanks.
I'll try this.
Last edited by OzTrekker; 03-22-2022 at 06:34 PM.
I've tried this Function and it always tells me the file exists at the URL irrespective of whether the file actually exists.
Am I missing something?
Is there a Reference that needs to be activated?
My URL looks like this "https://company.sharepoint.com/sites/ESUTeamPlanning/Shared Documents/ESU Files/Costing & Reporting/NG/Invoicing/2022/STTM/202203/MSV/QEN/20220323 MSV.pdf".
There is no reference needed. I did some testing on this for files in a public web site and it worked fine for me. I wonder if there is an issue related to the fact that you have to login to the site.
Jeff, maybe the problem is with the cache. You may need to clean it before checking it. I don't know much about it, so I just throw a thought. Or maybe I'm talking nonsense.
Artik
Atik, possibly, but this code does not use a browser, it sends the HTTP directly. I'm not sure if VBA maintains a cache.
Could you please explain how to test the coding 6StringJazzer posted? Thanks.
In a worksheet cell, it should be:Formula:
Please Login or Register to view this content.
![]()
Please Login or Register to view this content.
Trevor Shuttleworth - Retired Excel/VBA Consultant
I dream of a better world where chickens can cross the road without having their motives questioned
'Being unapologetic means never having to say you're sorry' John Cooper Clarke
Welcome to the Forum sarante!
Normally we prefer that new questions go in a new thread (please read the rules), especially since this thread is over 18 months old. But since your question is directly about an answer posted for the OP, and not some new twist, it should be fine.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks