I just tried to insert a TGraphic (TMetafile image) into my Editor, but didn't get it working
My first try was to find the Mailmergefields
Code
mmList := TWPTextObjList.Create; RichText.FieldGetList(mmList, TRUE); for i:=0 to mmList.Count-1 do begin mmItem := mmList[i];CopyChartToFile('d:\test.png');// Here also tried per stream or as EMF .... wpObj := TWPOImage.Create(RichText.Memo.RTFData);(* Also tried wpobj := TWPOImage.Create(tempDokument.RichText); wpobj.Graphic := tempGraphics;//Image1.Picture.Graphic; wpobj.WidthTW := wpobj.ContentsWidth; wpobj.HeightTW:= wpobj.ContentsHeight;*) wpObj.LoadFromFile('d:\test.png'); mmItem.ObjType := wpobjImage; mmItem.objRef := wpObj;(* Also triedmmItem.LoadObjFromFile('d:\test.png');*) end; end; mmList.Free;
-> All theses treis didn't do anything ... nothing appears on the resulting document
And i treid it also in the mailmerge event
Here also tried as PNG or as EMF, per file and per TStream
Code
procedure MailMergeGetText(Sender: TObject; const inspname: string; Contents: TWPMMInsertTextContents);
wpObj := TWPOImage.CreateImage(Contents.DataCollection, tempGraphics);
// wpobj.LoadFromFile()
Contents.obj := wpobj;
// and here also tried
CopyChartToClipboard;
WPRichText.PasteFromClipboard();
WPRichText.TextCursor.SelectToHere(Contents.StartInspObject);
Alles anzeigen
After this the whole document is duplicated -> all text are twice and the image of the charts is twice, but the first appearance of the image only a playeholder is seen (no image only the border)
What i am doing wrong?