Share via

Can i open sharepoint site docx file url using word js api from word desktop/web addin ?

Rajat Bharadwaj 5 Reputation points
2026-03-10T05:32:57.9666667+00:00

We have requirement to open a uploaded word document present in MS SharePoint site from word addin (desktop and web).

Expectation is if document is present in MS SharePoint , open a link to docx file so user can collaborate simultaneously with other users.

Is there a way we can achieve this? if not, any workaround to open a MS SharePoint file from word desktop/web ?

Microsoft 365 and Office | Development | Office JavaScript API
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Teddie-D 12,925 Reputation points Microsoft External Staff Moderator
    2026-03-10T06:45:11.7933333+00:00

    Hi @Rajat Bharadwaj 

    Thank you for posting your question in the Microsoft Q&A forum. 

    Word Add‑ins built with Office.js do not currently provide an API that allows an add‑in to programmatically open or switch to another Word document in the current Word client, either in Word Desktop or Word for the web. An add‑in is limited to interacting with the document in which it is currently running.  

    However, you can still meet collaboration requirements by opening the document through its SharePoint or OneDrive URL, for example: https://tenant.sharepoint.com/sites/siteName/Shared%20Documents/file.docx 

    -Word for the Web: The document opens in the browser and supports real‑time co‑authoring. 

    -Word Desktop: When opened from SharePoint or OneDrive, the document supports real‑time co‑authoring as well. 

    From a Word Add-in, you can launch the document link using: 

    Office.context.ui.openBrowserWindow(documentUrl); 
    

    This opens the SharePoint document in the browser, from which users can choose to continue editing in Word for the web or open it in Word Desktop. Both options preserve collaboration because the file remains stored in SharePoint or OneDrive. 

    If the add‑in downloads the file and opens it locally, Word will treat it as a local document and co‑authoring will not be available. To enable collaboration, the document should be opened directly from its SharePoint or OneDrive location. 

    Reference: Office.js API — Open OneDrive Files in Current Word/PPT Instance | Microsoft Community Hub

    I hope this information is helpful.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".       

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.  

    1 person found this answer helpful.

  2. Q&A Assist
    2026-03-10T05:33:14.9366667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Word JavaScript APIs do not provide a method to directly open a different SharePoint-hosted Word document (by URL) from within a Word add-in, either in desktop or in Word for the web.

    Supported behaviors around SharePoint/OneDrive documents are handled by the host (Word, SharePoint, or the browser), not by Office.js. Opening behavior (desktop vs web) is controlled by:

    • SharePoint / Office for the web configuration (for example, whether documents open in the browser or client by default).
    • Per-user link-handling preferences in Microsoft 365 apps.

    From the provided information:

    • SharePoint/Office for the web can be configured so that documents open in the browser or in the desktop client when clicked from a document library. This is controlled at the farm, site collection, or library level, not via Word JavaScript APIs.
    • For SharePoint 2013 with Office Web Apps, admins can change default open behavior (client vs browser) using New-SPWOPIBinding / Set-SPWOPIBinding, or by configuring the library / site collection to “Open in client application.”
    • For Microsoft 365 clients (Word, Excel, PowerPoint, Outlook), users can choose whether links to OneDrive/SharePoint documents open in desktop or browser via File → Options → Advanced → Link Handling / File open preference.

    Given this, the practical workarounds are:

    1. In the add-in UI, present the SharePoint document link (share URL) and let the user click it. The host/browser will then open it according to the configured behavior (Office for the web or desktop client), enabling coauthoring.
    2. Coordinate with SharePoint/tenant admins to configure default open behavior (browser or client) for the relevant libraries or farm, if the goal is to always open in the browser for real-time coauthoring.
    3. In Microsoft 365 desktop apps, instruct users to set their link-handling preference (desktop vs browser) so that clicking the link from Word/Outlook/PowerPoint behaves as desired.

    There is no supported Office.js API in the supplied material that programmatically forces Word to switch to and open another SharePoint document by URL from within the add-in.


    References:

    0 comments No comments

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.