How to Retrieve Local and Web Paths of an Excel Workbook from OneDrive using JavaScript API

Kashif Bashir Bhatti 36 Reputation points
2025-02-18T16:52:25.0666667+00:00

A OneDrive folder has been synchronized on a local machine, allowing workbooks to be opened directly from this folder. The local and web paths can be obtained using the Info => Copy path and Info => Copy local path options, as highlighted in the image below image.

The challenge is retrieving both paths in an Excel add-in developed using the JavaScript API. The Office.context.document.url property intermittently provides either the local path or the web path, but not both. Is there a method to obtain these paths from Excel using the JavaScript API, or are there any libraries, services, or hooks available to manipulate menu clicks to access this information, given that Excel already recognizes these paths?

Excel
Excel
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
2,175 questions
OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
1,321 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
1,044 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,277 questions
0 comments No comments
{count} votes

Your answer

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