Script to convert SharePoint URL to local path

Hi, Everyone,
I am here asking for help:
I have to deal with OneDrive (for Business) and SharePoint links a lot in my work, and one suffering point is that my colleagues will share a link pointing to SharePoint URL (of course, logical), and then I open the link in browser, and then realize it's located in my %userprofile%\OneDrive-Company\ShareName\xxx\yyy\zzz
I wonder if there's a logic that DOpus could get the URL from Clipboard, and get the local directory for me and open it?
I know it's a Christmas wish, but I found GitHub - cristianbuse/VBA-FileTools: Useful methods for interacting with the file system this link, and tried inside Excel VBA and it works! It convers SharePoint URL into local path!
Unfortunately, I couldn't manage this job limited by my programming ability, so I post here hoping someone capable happens to be inspired by this and could make it :smiley:

Thanks in advance.

What format are the URLs?

https://companyname.sharepoint.com/sites/msteams_fab02e/Shared%20Documents/Forms/AllItems.aspx?RootFolder=%2Fsites%2Fmsteams_fab02e%2FShared%20Documents%2FGeneral%2F02_Change_Management

it's syncing with my local path C:\Users\myname\OneDrive - companyname\%ShareName%\02_Change_Management

Here is the tricky part: the %sharename% is not automaticlly matching the URL pattern, because I just create one shortcut from That Teams Share\Documents\General into my OneDrive and rename it as e.g. "WholeProject", and this can be different from colleague A to B, he/she can map Teams Share\Documents\General\02_Change_Management into local path as C:\Users\myname\OneDrive - companyname\Changes

And the URL->Local-Path mapping is stored somewhere at Windows OS, and the github link I posted will get there and find the mapping therefore puzzle solved.

GetOneDriveLocalPath in the Github project you linked to seems to be the key. That's applying some guesswork to determine which local folder is most likely to be the one the URL links to, I think, based on similar strings in their names. Not ideal, but maybe the only way to do it.

It should be possible to do the same in an Opus script, but there are slight differences between VBA and VBScript which mean the code probably requires some changes. It's difficult to test without SharePoint installed, unfortunately.

This is interesting. We moved to Sharepoint from a local server in 2022 and it has caused quite a productivity hit. No option of moving back, mgt loves Sharepoint but down in the trenches we have to wade through the molasses to get work done. If only Dopus integrated with it. I have a side project to work on this with some tips from Leo but sadly don't have the time.

1 Like