Deleting a specific paragraph from a document using a macro

Under certain conditions, I need my macro to delete certain portions of a document. I can define an object varaiable and set it to ThisComponent, but I have no idea how to create a TextCursor object for it or delete the cursor’s text range. AndrewMacro.odt gives what looks like a pretty good explanation of how to set the desired range within the text, and I suspect I’ll be good to go there once I know how to define the TextCursor. But then, I have no idea how I will delete the contents of that range.

For example you have the variable oCur for TextCursor, then you can set empty string for it :-).

oCur=ThisComponent.Text.createTextCursor()
oCur.goRight(10, true) 'select 10 characters
oCur.String=""

Not sure I understand what your problem is. Is it a whole paragraph of text? Do you know the text of this paragraph? Well, or do you know that there are certain phrases in this paragraph? You may not need a text cursor.
The point is that you can ask the current component for all its text oText = ThisComponent.getText()
This oText has a .createEnumeration() method that will give you access to each paragraph of text. Now using the usual .hasMoreElements() or For Each (didn’t try it, check it out for yourself) just iterate through all the paragraphs of the document. Get .getString() from each and compare with the pattern. If this is the paragraph you want to get rid of, use the oText.removeTextContent(current element) method

In fact, I have described in words the last part Listing 8.18: Create a text table and insert cells - there, in the deleteTables() procedure, the same thing is done, you just have a different condition for If...Then