office365office-jsadd-inword-addins

how can I get Word.Section Range using office javascript api?


I want to get current Word Section range. where my cursor is clicked get there section rage.

this is like of Microsoft documentation

Word.Section class


Solution

  • Try using document.getSelection() to get the range where the cursor is. Then on that range object, call Range.parentBody. This will give you the body of the section that the cursor is in. Then on that body object use Body.getRange("Whole") to get the range of the whole section body.