How to get the current string of a text range?

When a document is in change tracking mode and a text range contains deletions, the string of the text range contains all deleted characters, just as when I enable showing them in the document pane. I would like to get the current draft text only. How should I go about that?


toggling View -> [ ] Track Changes isn’t what you are looking for? If the option is unchecked you don’t see the changes (and thus you see the current version of the document, regardless of the change-acceptance status) and if you tick again, you’ll see the changes again.

Hope that helps.

If the answer helped to solve your problem, please click the check mark (:heavy_check_mark:) next to the answer.

I cannot see the changes in the UI, so what? It does not affect the string returned by a text range. I guess there should be a way to get the current string because the spell checker somehow manages to do it.

For your start into further research: Place the insertion cursor somewhere in any paragraph containig recorded changes and run the code stepwise.

Sub Main
doc        = ThisComponent
sel        = doc.CurrentSelection(0) REM Assumed a single insertion cursor ("blinker")
paragraph  = sel.TextParagraph
For Each textPortion in paragraph
  REM Inspect the textPortion in the Basic IDE
  REM Regard '.TextPortionType' and '.String' in every case ...
Next textPortion
End Sub