Skip to content

Instantly share code, notes, and snippets.

@guwidoe
Last active June 2, 2025 13:41
Show Gist options
  • Select an option

  • Save guwidoe/6f0cbcd22850a360c623f235edd2dce2 to your computer and use it in GitHub Desktop.

Select an option

Save guwidoe/6f0cbcd22850a360c623f235edd2dce2 to your computer and use it in GitHub Desktop.
Cross-platform VBA Function to get the OneDrive/SharePoint Url path/link from a local path of a locally synced folder
' Cross-platform VBA Function to get the OneDrive/SharePoint Url path (link)
' from a local path of a locally synced folder (Works on Windows and on macOS)
'
' The functionality previously provided in this gist is now available in the
' 'GetRemotePath function from the following gist:
' https://gist.github.com/guwidoe/038398b6be1b16c458365716a921814d
' Please use that instead!
@Bowman99

Bowman99 commented Apr 9, 2024

Copy link
Copy Markdown

Hi @guwidoe,

I have run into a similar error that was found on GetLocalOneDrivePath.bas.vb

The debugger is shooting up error 457, “This key is already associated with an element of this collection”, at line 1164: locToWebColl.Add VBA.Array(locRoot, webRoot, email, _ mainSyncID, mainSyncFind, dirName), locRoot

This has since been fixed but has the same bug been applied here?

Appreciate the help!

Have you tried the last version?

@BlakeR94

BlakeR94 commented Apr 9, 2024

Copy link
Copy Markdown

yes, currently running the latest Updated: 2023/10/02

@guwidoe

guwidoe commented Apr 9, 2024

Copy link
Copy Markdown
Author

Hi @BlakeR94, thanks for the notice... You are right, not all bugfixes are implemented here. I will update the function today and let you know once its done!

@BlakeR94

BlakeR94 commented Apr 9, 2024

Copy link
Copy Markdown

Awesome, Thank you!

@guwidoe

guwidoe commented Apr 15, 2024

Copy link
Copy Markdown
Author

@BlakeR94, I have now updated the function, sorry for the delay!

@BlakeR94

Copy link
Copy Markdown

Working perfectly, thank you!

@monitom

monitom commented Sep 18, 2024

Copy link
Copy Markdown

Hi @guwidoe,

I am encountering the same error as BlakeR94: "Run-Time error '457': The key is already associated with an element of this collection."

It's on line 5530 of my code...

5530 locToWebColl.Add VBA.Array(locRoot, webRoot & "/" & cid, email, _ syncID, syncFind, dirName), Key:=locRoot

Not entirely sure why this would error here?

Thanks!
Tom

@guwidoe

guwidoe commented Oct 5, 2024

Copy link
Copy Markdown
Author

Hi @monitom and sorry for the late reply.
There seem to have been some OneDrive updates and I'll have to update this function accordingly.
Can you check if the GetRemotePath function from the current version of LibFileTools works on your machine?

@monitom

monitom commented Oct 11, 2024

Copy link
Copy Markdown

Hi @monitom and sorry for the late reply. There seem to have been some OneDrive updates and I'll have to update this function accordingly. Can you check if the GetRemotePath function from the current version of LibFileTools works on your machine?

Hi @guwidoe - No worries at all. Thanks for your reply.

GetRemotePath in LibFileTools worked correctly for my purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment