none
Word 2007 Merge Fields in RTF Issue RRS feed

  • Question

  • Hi,

    Hope this is the correct forum / section.  We use Word 2007 to create mailmerge documents and call these templates from our application to create emails / letters based on customer data. 

    Part of the process requires us to save the template document as RTF so that it can be imported into a seperate system which extracts the merge fields from the RTF document using a regular expression.  This has never been a problem in the past and works very well.  However, we have suddenly had a batch of documents that contain random RTF within the merge field definition.

    Normally the merge field definition looks something like this:

    {\field{\*\fldinst {\rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid4076926 \hich\af37\dbch\af37\loch\f37  MERGEFIELD dcm_lcrsappSTART_DAT }}

     

    However the random RTF merge field definition looks like this

    {\field{\*\fldinst {\rtlch\fcs1 \af0 \ltrch\fcs0 \insrsid6826706 \hich\af37\dbch\af37\loch\f37  MERGEFIELD dcm_courseSTAR\hich\af37\dbch\af37\loch\f37 T_DAT }}

     

    It appears that the following RTF is being inserted into the merge field definition:

    \hich\af37\dbch\af37\loch\f37

     

    Now the weird bit - if I open the template in Word, remove this merge field and re-insert in, save the file as .doc, then save as .rtf the merge field definition is correct, however a different merge field definition, that was correct in the original document is now wrong - the same piece of random RTF seems to "jump" around the document.  Every time you remove and re-insert a field the random RTF jumps to a different field.

    If I create a new document I can't replicate the issue, but documents from a number of other users seem to "affected".

     

    Does anyone have any ideas?

     

    Many thanks,

     

    Paul

     

     

    Wednesday, June 29, 2011 12:10 PM