Problem replacing Memo.SelText

  • Hello,

    I made a template-editor wich uses Texdynamic as rtf-editor.
    The user can define letters with tags wich are replaced later with the appropriate values.

    When I select a text with more than 3 end-of-line caracters in it i run into a problem.

    for example

    line1
    line2
    line3
    line4

    These are the lines selected (each with a end-of-line carater at the end)

    Code
    Dim text As String
    text = WPDLLInt.Memo.SelText
    WPDLLInt.Memo.SelText = text

    This is the code i use to read, add tags and replace the text. (the add tags parts i left out here because that's not the problem)

    line1
    line2 line3
    line3 line4
    line4

    This is the text that is replaced after the code above is executed.

    Am i doing something wrong, is there another way? The formatting needs to be replaced also
    When there are less than 3 end-of-line caracters in the selection it all works as i intended it to work. :?

    Thx ia.

    • Offizieller Beitrag

    Hello,

    Zitat

    Is there a way to retrieve te begin and end positions of the selected text?
    In that case I don't have to replace text at all. Just insert at the right positions.


    The best way would be to convert the tags into true merge fields.
    You can use this method for this:

    IWPTextCursor.FieldsFromTokens(StartText,EndText,FieldPreText)

    To replace selected text simply assign new text to SelText.

    To move to the end of the selection use Cursor.MovePosition(12,false)

    Regards,
    Julian Ziersch

  • Hello,

    problem is not replacing tags but placing them in the template.
    I want to place the tags around the selected text. But if the amount of text in Seltext is to much something goes wrong with placing in the document.
    I think it has something to do with the number of end-of-line caracters in the string.

    Regards,

    Joost.