- Offizieller Beitrag
Q: How can I merge the fields in different text blocks?
A: You can use WPRichText.MergeText('', true) to merge the fields in ALL text blocks.
If you need to limit the merge process to one text block use the MergeText procedure of the TWPRTFDataBlock:
function TWPRTFDataBlock.MergeText(
SenderForCallBack: TObject;
CallBack: TWPMailMergeGetTextEvent;
Readonly: Boolean;
const FieldName: string = '';
StartPar: TParagraph = nil;
LastPar: TParagraph = nil): Boolean;
You will have to pass the callback address, in fact this is your OnMailMergeGetText event procedure.
Readonly can be set to TRUE if you only want to read the fields (EmbeddedText). FieldName can be used to restrict the merge to certain fields. StartPar and EndPar is only used if you want to merge certain paragraphs.
So, to merge only the fields in the headers use
for i:=0 to WPRichText1.HeaderFooter.Count-1 do
if (WPRichText1.HeaderFooter[i].Kind=wpIsHeader) and
not (WPRichText1.HeaderFooter[i].IsEmpty) then
WPRichText1.HeaderFooter[i].MergeText(
WPRichText1,
WPRichText1MailMergeGetText,
false,
'', nil, nil );
Julian Ziersch
[/b]