In order to set a new selection in the document, the setBounds method is used. This method takes a SelectionBounds object as a parameter:
When a selection should be replaced with plain or formatted ext, the text needs to be selected first. After that, the load method can be used to replace the selected text.
The following code snippet selects text and inserts plain text into the selection: