Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Custom MailMerge

edited November 2005 in General
Hi,

I would like to use mail merge functionality in a ppRichEdit control. I know
database field replacement is possible in RB7 and is extended in RB9 but is
still not fulfilling my needs. I need the flexibility of RAP.
The idea is to give the user a passthrough procedure MailMerge with the
following signiture.

procedure MailMerge( RichEdit: TppCustomRichText; const Tag, Caption :
string );

He could call the procedure like this:

MailMerge( reLetter, '[CALC5]', Something );

to replace '[calc5]' by the variable 'Something' in reLetter.

The problem I am facing is getting an event after the mail merge done by RB
and before printing the result. All events seem to fire before the RB mail
merge takes place inverting my mail merge changes.

Am I missing something?

If this is not the case I think about introducing a new event for
TppRichEdit and make it visible in RAP.

OnMailMerge( RichEdit: TppCustomRichText )

It's called from TppCustomRichText.CalcSpaceUsed() after the call to
MergeDBFields();

Is this a correct approach?

Using RB 7.04 and Delphi 7.

Regards,
Jeroen R?ttink

Comments

  • edited November 2005
    Hi Jeroen,

    Creating an event such as the OnMailMerge as you describe would be a good
    approach however you would be forced to change the Interface section of the
    RB source, which will render RAP useless (as we do not ship the source to
    RAP). I'm a bit confused about why your changes are being ignored when
    changing the RichText text before it is processed by the RB mail merge. If
    you completely replace the mail merge tag, ReportBuilder should ignore that
    text as a possible data field.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2005
    Hi Nico,

    I didn't thought about that (no RAP source).
    I seems that the (for example) the OnPrint event is called and after this
    point RichEdit is being rendered.
    Part of this rendering process CalcSpaceUsed() is called which refreshes the
    richtext content by a call
    to LoadDrawRichEdit(). This is of course needed to get mailmerge working for
    each record traversal but
    is clearing my changes.

    Regards,
    Jeroen R?ttink

  • edited November 2005
    Hi Jeroen,

    If possible, could you please construct and send a simple example that shows
    what is happening that I can run on my machine in .zip format to
    support@digital-metaphors.com. I think if I can look at your code, I will
    be able to solve the problem easier.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.