WPCubed Product Support

Formatting Mail merge fields

Hi
How can I set the format in a template for a mail merge field and have that show up.

The field is a list of database rows. that I add ' \plain\fs22 ' + s + ' \par '; s being the row from the database.
I have tried to use the TParagraph object as well which gives me an extra line top and bottom.

What I want to be able to do is add a mailmerge field and set its format to bold or indented or bulleted in the template editor and for that format to be applied after the mail merge process.

TIA Jeff

#1 ♥ 0
6.5k Views 2 users read 6 min
support

Hi,

What I want to be able to do is add a mailmerge field and set its format to bold or indented or bulleted in the template editor and for that format to be applied after the mail merge process.

The merged text will use the attributes of the first field object, so you need to change the attributes before the field is inserted,. It is also possible to apply the attribute later.

I probably have difficulties to understand your post, esspecially wher you create RTF code.

Kind Regards,

Julian Ziersch

#2 ♥ 0

OK I'll try to explain it again.
We use WsTools in two ways

  1. Template Editor - allows uses to insert mail merge fields into text that look like

<<StudentName>> or <<StudentPapers>>

  1. As a Letter Generator run against the database and the previously described template.

<<StudentName>>is replacesd with Sid West in the mail merge event and the format that was applied to <<StudentName>> in the template applies to Sid West in the generated letter.

The problem I have is when I try to replace <<StudentPapers>> with
110 100 Accounting
127 101 Maths
127 207 Advanced Maths
The users want to apply format to the template, such as bullet points or numbering or bold etc..
When I resolve the mail merge field I get the rows from the database and concatenate them into a string with –

while not dataSet.Eof do
begin
s := '';
for i := 0 to pred(dataSet.FieldCount) do
begin
s := s + trim(dataSet.Fields[i].AsString) + ' ';
end;
result := result + ' \plain\fs22 ' + s + ' \par ';
end;
dataset.Next;
end;

and set this string into the letter with –
contents.StringValue := My_List_of Papers;

in the OnMailMergeGetText event

This replaces the field <<StudentPapers>> with the list of papers. But
if the field was bulleted only the first row of the list has bullet points.
If the field was bold no rows of the list are bold.
If the field was numbered only the first row is numbered.

I have tried using TParagraphs but this adds a blank row above and below the list and the bullets still donot work. a single bullet appears on the first blank row. In this case the code per row from the database is
par := rte.ActiveText.AppendPar;
par.SetText(s);

Can you help?

Jeff

#3 ♥ 0
support

Hi,

when loading RTF the component expects that is comes with all formatting to override the current.

There are same flags in
Contents.Options (in the OnMailMergeGetText event)

(mmStopNow, // aborts the merge process
    mmMergeTrim, // removes trailing spaces from the replacement string
    mmUseFirstLoadedParProps, // When loading RTF or HTML we also assign the paragraph props of the first ploaded paragraph
    mmUseFirstLoadedParPropsAuto, // use mmUseFirstLoadedParProps if the field is the first NON SPACE sign in the paragraph
    mmUseFirst_AlsoBorders, // refines "mmUseFirstLoadedParProps" to copy also the border and padding properties
    mmIgnoreNewParAttr, // If we are loaded in RTF or HTML string then paragraph attributes are preserved
    mmIgnoreNewCharAttr, // If we are loaded in RTF or HTML string then character attributes are preserved
    mmIgnoreLoadedFonts, // When loading RTF ignore the Fonts
    mmIgnoreLoadedFontSize, // When loading RTF ignore the Font sizes
    mmIgnoreLoadedFontStyles, // When loading RTF ignore bold/italic and underline
    mmMergeAsRTF,
    mmMergeAsHTML,
    mmMergeAsWPTOOLS,
    mmSkipSpacesBehind, // not used
    mmInsertObject,
    mmDeleteEmptyParagraph, // not used
    mmDeleteUntilFieldEnd, // not used
    mmDeleteThisField, //Delete the field markers!
    mmDontUseLoadedParTabs, // When loading RTF optionally IGNORE the tabs
    mmDontUseLoadedParStyle // When loading ignore the style

I think what you need is mmDontUseLoadedParStyle.

Regards,

Julian

#4 ♥ 0

OK
I have removed the rtf line breaks and replaced it with #13#10
I have changed the code in onMailMergeGetText
from
//contents.Options := contents.Options + [mmMergeAsRTF] ;
to
contents.Options := contents.Options + [mmDontUseLoadedParStyle] ;

The output now responds to bold, underline, italics and tab.
But only the first row is bulleted or numbered.
I still need to know how to get the bulleting to respond to the new lines in the list.

#5 ♥ 0

Is ther an answer to my previous posting

But only the first row is bulleted or numbered.
I still need to know how to get the bulleting to respond to the new lines in the list.

#6 ♥ 0
support

Hi,

The output now responds to bold, underline, italics and tab.

But only the first row is bulleted or numbered.
I still need to know how to get the bulleting to respond to the new lines in the list.<<

The option you need is:
mmIgnoreNewParAttr

Julian

#7 ♥ 0

No, still not working.

The RTF text produced looks like this.
\pard\plain\plain\fs22\par
\ls2\ilvl0{\listtext\f1 l\tab}\li1440\fi-360\plain\fs22\b{\field{\\fldinst{MERGEFIELD "DATA TABLE StudPaperListACYR" <MOD_DELIM13>4<MOD_DELIM01>DATA TABLE StudPaperListACYR<MOD_DELIM25>MMEU3R1ZFBhcGVyTGlzdEFDWVI=<MOD_DELIM04>MMEaaj+JogAA<MOD_DELIM14>-1}}{\\wpfldparam{DATA TABLE StudPaperListACYR}}{\fldrslt{110100 Introductory Accounting 0703 PNTH E
\line 110109 Intro Financial Accounting 0703 PNTH E
\line 199211 Invertebrate Zoology 0701 PNTH I
\line 143227 Signals, Systems & Information 0702 PNTH I
\line 199312 Behavioural Ecology 0702 PNTH I }}}\par
\pard\plain\plain\fs22\par

As you can see list formatting is not going into the fldrslt.
I can put it there in code - if I can tell it should be there.

Is this a possible solution? If so, can you tell me how I can tell that a bulleted list has been applied to the line of the merge field. I need to know this in the onMailMergeGetText.

#8 ♥ 0
This category is archived. No new posts are possible.