Macros/Writer/007

Description
This Basic macro for Writer identifies text contained between two boundary strings (i.e. a "start tag" and an "end tag"). For example, the text which is found between the beginning and end of an explanation.

The principle is to search for a unique "start tag" which gives a starting position to search for the "end tag". These two positions are selected via the visible cursor from the end of the "start tag" to the beginning of the "end tag".

The search is performed using the createSearchDescriptor method of the ''' com.sun.star. util.XSearchable interface along with the  com.sun.star. util.SearchDescriptor''' service to define the properties of the search, including: search text, case sensitivity, use of regular expressions, etc.

''' com.sun.star. text.XTextViewCursor''' service is used to display the located text.

Code
In the below code, the start & end tags are "start of explanation" and "end of explanation", respectively. With Pythonː Python standard output file is not available when running Python macros. Input/Output to Screen help page exposes alternatives.

ODT file to test macro

 * [[Media:EN.MACROS Writer 007 Search and highlight text found between two tags.odt|Download example ODT file with this macro included]]