You've got the problem backwards I think. There is no information in the Attn part and the part following Dear is almost certainly not the same as the information I need in the Attn part. As an example:
Attn: John Smith, Manager
Dear Mr. Smith,

or

Attn: Public Relations Manager
Dear Sir/Ms,

I can only get the relevant information from the database fields.

re. Search & Replace to remove the Attn: - I tried that but couldn't get it to match the end of paragraph - and your solution (from your AndrewMacros.odt to remove empty paragraphs is quite baroque - uses way too much code - when all I need is to go to the next paragraph. :)


Andrew Douglas Pitonyak wrote:
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to