- Offizieller Beitrag
Q: In our current code, we need to change the font style of the bookmark embedded text.
A: To do this most effectively you can use this code:
add an event handler for OnMailMergeGetText
Code
procedure TForm1.WPRichText1MailMergeGetText(Sender: TObject;
const inspname: string; Contents: TWPMMInsertTextContents);
begin
if Contents.StartInspObject.ObjType=wpobjBookmark then
begin
TWPRichText(Sender).CurrAttr.BKColor := TWPRichText(Sender).CurrAttr.ColorToNr(clYellow, true);
TWPRichText(Sender).CurrAttr.Color := TWPRichText(Sender).CurrAttr.ColorToNr(clRed, true);
TWPRichText(Sender).CurrAttr.AddStyle([afsBold]);
end;
end;
and make this event beeing called for each bookmark:
WPRichText1.MergeTextEx('','',wpobjBookmark,[wpmergeAllTexts]);