Insert multiple Mergefields after another

  • Hi Julian,

    When using the code below to insert mergefields following will happen:
    The first field will be inserted as expected into the WPRichText.
    The next field however won't be inserted although the code for inserting is executed.
    If I press the enter-key (after inserting the first field, the second field will be inserted normally.

    Code
    if lbVeldenLijst.ItemIndex < 0 then    ShowMessage('Selecteer a.u.b. eerst een samenvoegveld in de lijst!')  else    MailingEditor.InputMergeField(lbVeldenLijst.Items[lbVeldenLijst.ItemIndex]);

    I got the code from the "MailM4"-project in the demo folder. It seems the second mergefield is inserted within the first mergefield and therefor omitted/lost.

    Also implementing the changes in WPCtrMemo made no difference.
    See: http://wpcubed.com/forum/viewtopic.php?t=3358
    For the first inserted mergefield the code is executed

    Code
    if (spar <nil>= spar.CharCount) then       sposinpar := spar.CharCount - 1;


    But for the second inserted mergefield the code below isn't executed.

    Code
    sposinpar := spar.CharCount - 1;


    Can you please tell me how to resolve this behaviour?

    Regards,
    Stef

  • Hi Julian,

    Thank you for your reply by E-mail. In order to complete this forum-question I will add some additional info here too.

    Basically the problem was not in adding the mergefield, but I had done some workaround in order to show the name of the mergefield directly after it was inserted. In that code it went wrong. Julian gave me a simple solution for that, by passing the name as a second parameter.

    Code
    MailingEditor.InputMergeField(list1.Items[list1.ItemIndex],
       list.Items[list.ItemIndex]);


    By the way: You will need to make the change to WPCRTMEMO.pas as described in http://wpcubed.com/forum/viewtopic.php?t=3358 (WPTools 5.30.3).

    Regards,
    Stef