Have you considered solving the problem using search and replace to
remove the Attn.
As for obtaining the part after "Dear". You search for Dear. You know
that it is followed by a person's name.
I would have a text cursor position itself to the end of the Dear and
then have it move to the end of the paragraph while selecting the text.
You can then extract the string from the cursor using Cursor.getString().
Gary Dale wrote:
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]
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info: http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]