Mailmerge or ?

  • Some questions :

    1.) What is the best method, to insert a calced field ?

    I need something like a Mailmerge field but it's not a name which i would like to store, it is a calculation and this calculation can have special Chars (like ', ", $, @ ....)
    I tried to use a standard Mailmerge and save it in the name, but the " are replaced.
    Is in the TWPTextObj a field were i can store this info ? Or is it possible to create an new Object derived from TWPTextObj ?

    2.) What is the easiest way (and as less visual object as possible) to Mailmerge a text ?

    3.) How can i loop trough all MailMerge objects (is it only possible to call mailmerge ?)

    4.) Is there an event if the user enters text into a mailmerge field (or changed the text) ?

    5.) In the demo "EditFields" the checkbox doesn't load and save the value, what is the easiest way to get this working ?

    • Offizieller Beitrag

    Hi,

    1.) What is the best method, to insert a calced field ?

    Mailmerge is one of the most powerful features in WPTools. I strongyl recommend to use it.

    If you need formulas store them in the "Source" part of the mail merge field. The name should not contain any spaces and really not special characters. It cannot contain ' or " signs. You will have to replace those using an escape sequence. Optionally you can hexencode the string - those strings are quite frequently used in RTF files created by Word.

    2.) What is the easiest way (and as less visual object as possible) to Mailmerge a text ?

    You can do MailMerge in a TWPRTFDataBlock. So you can do a mail merge with a TRTFDataCollection and dont need a TWPRichText, memo ro similar. Just the collection. The MailMerge function defined in TWPRTFDataBlock requires a callback function, that is the procedure wich would normally handle the OnMaileMergeGetText event. (See PDF manual)


    3.) How can i loop trough all MailMerge objects (is it only possible to call mailmerge ?)

    This function list a list with references to fields which all start with
    a given text. The comarision is case sensitive! This list which will be filled must be created:

    Code
    list := TWPTextObjList.Create; 
        procedure FieldGetList(
          list: TWPTextObjList; FromAllBlock: Boolean = FALSE;
          NameStartWith: string = '');

    4.) Is there an event if the user enters text into a mailmerge field (or changed the text) ?

    No, the stanadrd KeyPerss can be used - FieldAtCP can be used to check if the cursor is inside of a field. In protected mode all othere text can be protected, too.

    5.) In the demo "EditFields" the checkbox doesn't load and save the value, what is the easiest way to get this working ?

    The 'params' property is used to store the value. Probably the easist would be to store the value directly in the Click event where the state is changed. Alternatively You can use the function CodeListTags to get a list with all wpTextObj instances to read/set their value. (Note: The check boxes are no mail merge fields.)

    Regards,

    Julian

  • Thanxs for the fast response.

    If i use a Mailmerge field, and store the data in the Source Field (also tried it in the Params Field) i get the problem that if i copy the field (in the editor copy and paste) the additional fields are not copied and if i try to save and load (RTF and WPTOOLS) the additional fields are also empty

  • Is it possible to get these twoe fields (Params, Source) saved to file and copyied if i copy and paste the text, or should i check some other possiblities than the MailMerge field ?

  • I just found my error :

    I tried following :

    Code
    with TemplateEdit.InputEditField(SelectField.Text, SelectField.Text) do begin            Params  := 'TEST';            Source  := 'TESTSource';end;

    But the problem is, that InputEditField returns the EndTag and not the main Field (By the way is there a short possibility to get the main Field form an start or End Tag ?)

    It confused me, that the parameter in the InputEditField has the name Command and not Source.
    Now with this code, i get the text correctly into the Source parameter

    Code
    tmp := TemplateEdit.InputEditField(SelectField.Text, SelectField.Text, FALSE, 'TESTSOURCE''"\@');

    But now i have two problems :
    *) If saving to RTF, i get problems with \ (I has to replace all \ with \\)
    *) If saving to WPT i get problems with the " (the same thing if i copy and paste the text)