Collection As rtCollection
Returned by Find or FindNext methods of rtContainer. Used to insert text or any rich text objects (see Insert method).
Use Collection method to retrieve all text objects. The collection contains rTextRun and rtLabel objects. In simplest case it will be one rTextRun object. However between the begin and end of the range may be sections, buttons, graphics and other objects that contain Labels. To define which labels should appear during text search/replace operations, use defineLabelAsText property of rtContainer.
There is also a specific labels -- rTextParagraph labels that contain paragraph break code and starts each paragraph. First paragraph usually does not contain this label (there is no return character(s)) before the first line of text. These labels are present always if found text crosses the paragraph boundaries. Any text entered in paragraph labels is ignored.
set rtr = ctx.Find ("Peter*Paul", RT_FIND_WILDCARDS)
This statement returns a rTextRange containing all rTextRuns and labels as defined by defineLabelAsText. It returns also paragraph labels if "Peter" and "Paul" are in different paragraphs. Next statement:
set rtr = ctx.FindNext ("Ceasar", 0)
will return next occurence of "Ceasar" after "Paul". Flag "0" corresponds to "case sansitive, pitch sensitive" option of case sensitivity flags used by Instr function. If you use RT_FIND_WILDCARDS this is the only available option (other flag values are ignored).
Use Collapse method to move insertion point to one end or other. After Find/FindNext method, following Insert will overwrite all text with the Insert argument. In case Insert argument is not a string but other object it is inserted in place of selected text. Calling Collapse with parameters RT_COLLAPSE_START or RT_COLLAPSE_END will move the selection to one end or other and will not overwrite.
setStyle allows to apply any style - either rtStyle or it's components like rtFontstyle, rtParagraph styler, etc. The style is applied to all elements, text or not between begining and end of the text phrase.