Forum Discussion

nitika-optimus's avatar
nitika-optimus
Copper Contributor
Jul 21, 2026

Office.js: Is there any supported way to retrieve multiple non-contiguous text selections in Word?

Hi everyone,

I'm developing a Word Office Add-in using Office.js.

In Microsoft Word (Windows Desktop), users can select multiple non-contiguous text ranges by holding Ctrl while selecting text.

However, when I use:

context.document.getSelection()

It only returns a single Word.Range, and I couldn't find any API to detect or retrieve all the selected ranges.

 

I came across this related discussion:

Microsoft Tech Community – Support for Retrieving Multiple Selected Ranges in Word via Office.js

My questions are:

1. As of 2026, is there any supported Office.js API to retrieve multiple non-contiguous text selections?

2. Is there any workaround to detect that the user has selected multiple ranges?

3. Or is this still a platform limitation?

 

Our use case is an AI-powered legal research add-in, where users may want to select multiple clauses from different parts of a document and send them together as context.

Any guidance would be appreciated. Thanks!

4 Replies

  • What do you want to do with the non-contiguous ranges?

    You could individually select each range and copy it to another document and then after all of the individual ranges have been selected and copied, select all of that other document.

    • nitika-optimus's avatar
      nitika-optimus
      Copper Contributor

      Our use case requires us to detect the range of text which is selected based on specific user action in a side panel for an Add In that we are creating. The user can initiate deselection of any previously selected passage from the side panel using an indicator that we have created.

      We need a mechanism to address that specific selected portion, which may not be the last one selected.

  • Select the first block of text and then while holding down the CTRL key, left click and drag from the beginning to the end of any subsequent blocks of text that you want to select.  Below is a screen shot of that application of that procedure:

    In the case of multiple words, instead of left clicking and dragging with the CTRL key held down, you can double left click with the mouse with the CTRL key held down and likewise for selecting a complete paragraph, you can triple left click with the mouse.

    • nitika-optimus's avatar
      nitika-optimus
      Copper Contributor

      Thank you for your response and for explaining how multiple non-contiguous selections can be made in Word.

      My question is specifically about the Office.js API, rather than how users create the selection in the Word UI.

      I understand that Word supports multiple selections using Ctrl + click/drag. However, when my add-in calls:

      context.document.getSelection()

      it only returns a single Word.Range.

      Is there any supported Office.js API to retrieve all of the selected ranges, or to detect that the current selection consists of multiple non-contiguous ranges?