WPCubed Product Support

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.

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

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

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

sposinpar := spar.CharCount - 1;

Can you please tell me how to resolve this behaviour?

Regards,
Stef

#1 ♥ 0
5.8k Views 2 links 3 users read 2 min
support

Hi,

I don't have a problem with this:

WPRichText1.InputMergeField('NAME');
WPRichText1.InputMergeField('NAME');

Executed for an empty paragraph.

Julian

#2 ♥ 0

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.

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

#3 ♥ 0

Stef,

Thank you very much for tying this thread up so neatly. It's appreciated.

I was following this one with personal interest, as I've run into similar situations.

Regards,
richard diamond

#4 ♥ 0
This category is archived. No new posts are possible.