I use Contents.MergePar.AppendNewTable() and so on.
This basically inserts the table but above the table the name of the merge field is visible. It seems that it left the paragraph with the mail merge field untouched and instead it appended a new paragraph and added the table to that new paragraph.
I would rather like the table inside the paragraph where the merge field resides. I couldn't find an "InsertNewTable" instead of an "AppendNewTable". But maybe my whole approach is wrong.
Can you please explain to me how I can insert a table in a mail merge?
Right now it works like that - the start and end field marker remain and the table is inserted between. It is not inserted INSIDE that paragraph since a table is not an object like an image but a paragraph object.
You used "Contents.MergePar.AppendNewTable() " which is the incorrect way to add a table inside a field because it does not add it INSIDE the field but under the paragraph which contained the field.
You need to call the TWPRichText directly.
First ClearSelection and then
function AddTable(colcount, lincount: Integer; Border: Boolean = TRUE)
: TParagraph;
I am afraid I still don't get it. Hier is my code:
procedure TRtfSerienbriefMgr.OnGetTextToInsert(Sender: TObject;
const inspname: String; const Contents: TWPMMInsertTextContents;
var Done: Boolean);
var
lRtf: TWPRichText;
lPar: TParagraph;
begin
if (inspname = 'OIMMO_TABELLE_TYP1') then
begin
lRtf := TWPMMDataProvider(Sender).EditBox as TWPRichText;
lRtf.ClearSelection;
lPar := lRtf.ActivePar.AppendNewTable;
// use lPar to populate table
end;
Done := true;
end;
This at least doesn't show the merge field name anymore (thanks to ClearSelection) but still the table is appended below the merge field and does not replace the field itself.
I assume it's either because I call "AppendNewTable" or I use ActivePar. I don't want to use the AddTable method because I want to create the table row by row in a loop.
I would really appreciate if you could give me a few lines of code that show how you would implement OnGetTextToInsert.
As I wrote, You need to call the TWPRichText directly : WPRichText1.AddTable.
Example:
procedure TForm2.WPRichText1MailMergeGetText(Sender: TObject;
const inspname: string; Contents: TWPMMInsertTextContents);
begin
if inspname='TEST' then
begin
WPRichText1.ClearSelection;
WPRichText1.AddTable(3,3,true);
end;
end;
#8♥ 0
This category is archived. No new posts are possible.