Getting there! The code below seems to work up to what I'm asking it to
do. I search for just the text, create a cursor where it's found then
select everything to the next paragraph and delete it.
Now I just need to insert the database information for whose attention
is should be sent to (if anyone).
REM ***** BASIC *****
REM ***** insert "Attn:" line when needed *****
REM ********************************************
Sub Main
Dim Doc As Object
Dim FoundAt As Object
Dim InsertPoint As Object
Dim SearchDesc As Object
Dim ReplaceDesc As Object
Doc = ThisComponent
SearchDesc = Doc.createSearchDescriptor()
SearchDesc.searchString = "Attn:"
SearchDesc.searchCaseSensitive = True
SearchDesc.searchWords = True
SearchDesc.searchSimilarity = False
FoundAt = Doc.findFirst(SearchDesc)
IF NOT IsNull(FoundAt) THEN
InsertPoint = Doc.Text.createTextCursorByRange(FoundAt)
InsertPoint.gotoNextParagraph(True)
InsertPoint.setString("")
END IF
SearchDesc.searchString = "Dear"
FoundAt = Doc.findFirst(SearchDesc)
IF NOT IsNull(FoundAt) THEN
InsertPoint = Doc.Text.createTextCursorByRange(FoundAt)
IF NOT InsertPoint.isStartOfSentence() THEN
InsertPoint.gotoStartOfSentence(FALSE)
END IF
Doc.Text.insertString(InsertPoint, "Attn: ", False)
Doc.Text.insertControlCharacter(InsertPoint,
com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
END IF
End Sub
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]