I want to check to see if a folder exists on sharepoint......not sure how to do this.
when i try to use Dir(path, vbdirectory) it does not work.
I want to check to see if a folder exists on sharepoint......not sure how to do this.
when i try to use Dir(path, vbdirectory) it does not work.
I have tried the following vba code to check if folder exists and it does not work:
Save_pth = "https://CompanyName-my.sharepoint.com/personal/john_doe_companyname_com/Documents/Usage_test/"
'**********************************
'******check if folder exists******
'**********************************
FolderExists = False
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FolderExists(Save_pth) Then
FolderExists = True
MsgBox ("folder true")
Else
FolderExists = False
MsgBox ("folder false")
End If
'
'
'
'**********************************
'*********Another approach*********
'**********************************
'******check if folder exists******
'**********************************
Dim strFolderExists As String
strFolderExists = Dir(Save_pth, vbDirectory)
If strFolderExists = "" Then
MsgBox "The selected folder doesn't exist"
Else
MsgBox "The selected folder exists"
End If
Try to sync the high level folder with your explorer first.
You find “sync” on the sharepoint library
not sure what your trying to tell me
If you sync the sharepoint folder to your explorer, your code will work
this syncing.....can it be done via vba or does one need to do this manually?
since other people are going to want to use this macro it would need to be done via vba and not manually
is there another way other than "by syncing" to check if file is in a sharepoint folder?
I think the best is first to ask to your IT …
IT did not know anything.
Question: i am not sure but i "think" the issue is the "path".
In the past when i wanted to see if a file or directory was present i used the code shown above.
But now it does not work and i think its due to the path one being on hard drive and one being a URL....
Any thoughts?
As a reminder VBA like FSO was created before such tool exists …
So to have a chance with FSO is to map a local drive on sharepoint folder as a root, somewhat people call 'sync'.
So you may have more chance to ask on a specific OS / sharepoint forum first for this technical part …
i am kind of stumped. I talked to IT they have no idea what to try/or do and to them its not their problem its mine.
So let me restate my question maybe this time i say it differently.
I need to know if when i try to save a file to a location on a sharepoint server if the file was saved or not.
I CAN NOT use sinc, at least i dont think so because i am writing this macro for others to use not just myself.
is there some way to check if one has permission to access a server site or something .... i just dont know.
An indirect way at VBA beginner level for example is to try to create a text file : ok if that not raises any error …
I wrote code for saving files in sharepoint. But again, you have to dive into “synchronising” files. Everyone who has to use the macro, needs to sync.
It’s the easiest method
https://support.microsoft.com/en-us/...1-53f3e18bea9b
Another method is to import all folders and subfolders with Power Query into your Excel file.
Then check if the specific folder exists in the table
Last edited by JEC.; 05-25-2023 at 01:53 PM.
Jec, can you send me some code where you use power query to import all file names in a folder of sharepoint
Hi all who responded thanks!
Question1: Still trying to chk if file was saved and/or exists without syncing........not sure this is really going to be an option for me.
What i dont understand is why isnt there some sort of code out there that can check if file at a specific server location exists. I have searched and
serached and tried all kinds of silly and not so silly things and NOTHING seems to work. I am not an expert in programming but i know there has to
be a way to test if a file exists or not. IF person does not have read/or/write access to a specific location then file does not exist to them.
Before i concede and start looking into syncing you mentioned power query.......what is this and how would i use it to see if file exists or if i
have access to server location?
There is some “graph” code available. I don’t have experience with that
Alan עַם יִשְׂרָאֵל חַי
Change an Ugly Report with Power Query
Database Normalization
Complete Guide to Power Query
Man's Mind Stretched to New Dimensions Never Returns to Its Original Form
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks