Get RTF from mailmerged field

  • I do "cascading" mailmerge!

    I had put option into program to edit editfields and merge the editfields and mergefields again.

    I create a MergeEngine class to merge the document.

    Code
    procedure TMergeEngine.DoMergeGetText(Sender: TObject;  const inspname: string; Contents: TWPMMInsertTextContents);begin  FCampo.LoadFromWPObj(Contents.StartInspObject);  if (FCampo.Tipo = cTC_Modelo) then  begin    Contents.Options := [mmMergeAsRTF];    Contents.StringValue := SubMerge(FDataEngine.DoGetValue(InspName), FCampo)  end else    Contents.StringValue :=      FormatValue(FDataEngine.DoGetValue(InspName), FCampo);  FCampo.SetVariable(cMerged, 'True');  Contents.StartInspObject.Source := FCampo.ConfigToString;end;


    On merge, when (FCampo.Tipo = cTC_Modelo) Contents.StringValue is a formatted text ('{\rtf1\ansi\deff0\uc1\ansic.......MAL -\par'#$D#$A'}}')

    All ok here, but i need that the user can change some field of database and he could remake the merge, but not lost changes that he did out of fields!

    Then I create a ReadConfig class to read fields of merged document:

    but Contents.StringValue not return a formated text, just a plain text.

    How I can get a field content as RTF formated?

    I tried put Contents.Options := [mmMergeAsRTF] on TReadConfig.DoMergeGetText but I dont have luck! :(

  • I did not really look deep into your problem, but with Julian on vacation I thought I'd quickly mention "Contents.OldFormattedText" that I've used in the past to get the formatted string.

  • Thanks, I found Contents.OldFormattedText too in spite of the formated text be a little diferent of what first merge put on stringvalue.

    thanks to god, this diference dont change the format! :)

    • Offizieller Beitrag

    Hi,

    good you found OldFormattedText - you can also use SelectionAsString - in fact inside the OnMailMergeGetText event the field is actually 'selected'. That is a big difference to WPTools 4' mail merge.

    Julian