VBA vs OneDrive: is it possible to use "Copy Link"s to work with files/folders?

Eugene Z 20 Reputation points
2025-06-18T14:10:11.63+00:00

VBA Word "Documents.Open" and "Document.SaveAs2" works with local files;

but when OneDrive is present - they can also work with network path, like

https://companyname.sharepoint.com/sites/ap/Shared%20Documents/Some%20Report/tstFo/1.xlsx

Problem: we are dealing with filename-length limitation of 255 chars, and the network paths are not much shorter (if not longer) than the local paths.

There is another way to identify a file or a folder on OneDrive - you can get it's "Copy Link", which looks like this:

https://companyname.sharepoint.com/:w:/s/Testing/ETuWSEOz6UVFnY-mzT5AO0YB_xR8CkLNeuXaCVqzLkGawL

It has the obvious advantage of being short - so the filename-length limitation would go away.

Can it be used to access the files, using VBA?

Thanks!

Developer technologies | VB
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Susmitha T (INFOSYS LIMITED) 1,630 Reputation points Microsoft External Staff
    2025-11-17T08:57:12.2233333+00:00

    Thanks for reaching out!

    No- OneDrive/SharePoint "Copy Link" URLs cannot be used in VBA. They are sharing links and do not point to the actual file.

    What works: Local OneDrive-Synced path, Full Share- file URL (long URL)
    Workaround: Sync the SharePoint library using the OneDrive client to get a shorter local path.

    Let me know if you need any further help with this. I will be happy to assist.

    If you find this helpful, Kindly mark the provided solution as "Accept Answer", so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.