• I have two questions

    1) If an infopower datasource TwwDataSource is used to attach a table to a WPMMDataProvider instead of a TDataSource, the mailmerge4 demo does not display the field values when

    WPRichText1.InsertPointAttr.hidden := False;
    formMailMerge.WPMMDataProvider2.ShowFieldNames := True;

    Is there a solution for this?

    2) If an existing template containing mailmerge fields is opened in a WPRichText component is there a mechanism to determine via code:
    a) if the document, in fact, contains mailmerge fields,
    b) what the name of the database field referenced by the mailmerge field is and
    c) the name of the database table that is referenced?

    TIA

    John

  • bearing in mind I am very new to Wptools, so there might be another way to do it or a cleaner way to do it. but

    2.a
    I would attempt a merge

    Document.MergeText('', true);
    Document.ReformatAll;

    and set a flag in the OnMailMergeGetText event to determine if I went through that event (ie there are merge fields)

    For b and c, I would use the field names when I create the merge field in the document template to specify what I need and use the again the same event (OnMailMergeGetText) to build a list of all the fields

    Hope I am not sending you on a wrong path

    Didier

  • Answer to 2a)

    Mechanism to determine if merge fields are present
    procedure TformWordProcessor.SpeedButton2Click(Sender: TObject);
    var
    tempTextObjList: TWPTextObjList;
    I: Integer;
    begin
    tempTextObjList := TWPTextObjList.Create;

    WPRichText1.FieldGetList(tempTextObjList, True, '');

    if tempTextObjList.Count > 0 then
    begin
    showmessage('Merge fields present');
    for I := 1 to tempTextObjList.Count - 1 do
    begin
    showmessage(tempTextObjList.Items[I].Name);
    end;
    end
    else
    begin
    showmessage('Merge fields not present');
    end;
    tempTextObjList.Destroy;
    end;

    John

    • Offizieller Beitrag

    Hi John,

    thanks for the answer, FieldGetList is certainly a good way to work with fields. Bu usually I recommend to Use MergeText. ReformatAll is not required if the text was not modified.

    This was the answer I sent you in reply to your e-mail question:

    I cannot reach anybody using a comcast e-mail account. I recall that I tried to send you several e-mail in the past which were all blocked. This company (comcast) blocks any e-mail and there is no way to get around it.

    Zitat

    c) the name of the database table that is referenced?

    This is only possible by looking which table has the field. The dataprovide use FindField.

    You can, btw, do very nice data merging without the wpdataprovider. You only need the OnMailMergeGetText event. In the PDF there is a chapter about it.

    Regards,

    Julian