[Merge] Headers and Footers.

  • I have an RTF file which contains a header and footer. Both header and footer contain fields that need to be mail-merged with some data but whenever I call "WPRichText.MergeText" it will just merge the text in the main body, but not in the header and footer.

    Let me explain more precisely what I am doing, though. First, I start with a Word document which I save as .RTF by using the OLE automation interface of Word. This becomes a copy of the original document and the basis for the merge document.
    In this original document, the user has provided space for the merge fields by using something like <#Fieldname> in the original document. I thus use:
    WPRichText.ReplaceTokens( '<#', '>' );
    This will convert those user-defined fields into WPTools fields. I then do a few more calculations before the MergeText function gets called.

    In the resulting document, the fields in the main body have received the proper values. Unfortunately, the headers and footers still contain the texts <#Fieldname> so it appears ReplaceTokens doesn't work on those.

    So, what am I missing here?

    • Offizieller Beitrag

    You can use this utility procedure: (add it to unit WPCtrMemo)

    This procedure will be in the upcoming 5.13