For a Text object named myText containing the value Mr James Smith, use the following syntax:
var selectedArea = myText.GetSelection()
Note:
If the currently selected text within the Text object myText was the word James, the Return Value of start would be index position 3, and for end, index position 8. In this example, the selectedArea variable becomes an object that has two properties named start and end. To check the value of start or end save the property to a variable in a Script or as a Page or Publication variable displayed on a page within Opus. For example, to save the properties to two Script variables named startSelection and endSelection
var startSelection = selectedArea.start;
var endSelection = selectedArea.end;