We are using sharepoint, and I have some folder synced to my PC.
I would like to use excel vba to access those files. Is there an easy way to find the path to this synced sharepoint folder (not in the cloud, but a path to my local copy)?
We are using sharepoint, and I have some folder synced to my PC.
I would like to use excel vba to access those files. Is there an easy way to find the path to this synced sharepoint folder (not in the cloud, but a path to my local copy)?
path to your local copy? not really understanding that. VBA can look literally anywhere. but server addresses start like this:
![]()
\\dir\dir\dir\dir\file.extension
See my comment to the thread below of AliGW
When you synch a SharePoint folder to your desktop, the file path will be something like this:
C:\Users\username\friendly name of company\department folder - Documents
Ali
Enthusiastic self-taught user of MS Excel who's always learning!
Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.
NB: as a Moderator, I never accept friendship requests.
Forum Rules (updated August 2023): please read them here.
I do have that. My issue is that I have multiple persons using the macro and I do not know by heart how they organized their local synced sharepoint copy. So the drive letter might be different as well as the friendly company name.
At the moment, I have to ask them to place a shortcut (link to sharepoint) in the favorites folder. I can search that one to see if a link is present. This is a workaround which costs time.
I was hoping to find the path using environ("sharepoint") or similar.
there is no environ("sharepoint") i don't believe. sharepoint is not part of the windows path.
That was the first thing I tried. Sharepoint is by Microsoft, Windows is by Microsoft, so would be obvious.
I can find the onedrive link (that is in environ). Sharepoint is using onedrive for business but no go.....
Folder and/or drive structure should really be managed by your IT group and standardized, using GPO via Active Directory Management (ex: using logon script).
At any rate, if local drive can change, then you should use Environ("UserProfile") this will give X:\Users\UserName.
Then you can use FileDialog to return all folders within that path and have user pick the folder they need.
Ex:
Alternately, you could use recursive logic to traverse user's folder to find folder that contains "- Documents". But I don't recommend this approach as it could a while and/or unreliable, depending on user's folder structure.![]()
Sub Demo() Dim myFold As String With Application.FileDialog(msoFileDialogFolderPicker) .AllowMultiSelect = False .InitialFileName = Environ$("UserProfile") & "\" If .Show Then myFold = .SelectedItems(1) & "\" End With If Len(myFold) = 0 Then Exit Sub 'Do something with myFold End Sub
"Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something."
― Robert A. Heinlein
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks