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.
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:
procedure TReadConfig.DoMergeGetText(Sender: TObject;
const inspname: string; Contents: TWPMMInsertTextContents);
var
index: integer;
sValor: string;
begin
sValor := '';
if wpobjWithinEditable in Contents.StartInspObject.Mode then
begin
FCampo.LoadFromWPObj(Contents.StartInspObject);
if (FCampo.Tipo = cTC_Modelo) or not
FCampo.GetVariable(cValor_Original, sValor) then
sValor := Contents.StringValue;
index := FEnviroment.IndexOfName(inspname);
if index <> -1 then
FEnviroment[Index] := inspname+'='+sValor
else
FEnviroment.Append(inspname+'='+sValor);
end;
end;
Alles anzeigen
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! :(