Board index » delphi » Insert Rich Text into a Rich Text file

Insert Rich Text into a Rich Text file

I need to be able to search through a RTF file... looking for a particular
"word"... and if found I need to replace the "word" with another RTF file.
In other words... insert an RTF file into the middle of another RTF file...
not just append the 2nd RTF to the end of the 1st RTF.  I've looked over
some of the articles about GETRTFSelection & PutRTFSelection... but I guess
I'm just not understanding how to use them... any pointers would be greatly
appreciated.

Thanks,

Joe Hutchins

 

Re:Insert Rich Text into a Rich Text file


Quote
In article <3be74a58$1_2@dnews>, Joe Hutchins wrote:
> I need to be able to search through a RTF file... looking for a particular
> "word"... and if found I need to replace the "word" with another RTF file.

Let's clear up a few things up front. Do you want to do that on *disk files*,
that is: not involving any visual component like a TRichedit? It can be done,
no question, but you need a very good understanding of the internal structure
of an rich text file to make this work. Or do you want to do this in a rich
edit control?

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.

Re:Insert Rich Text into a Rich Text file


Peter,

The RTF "file" I need to update is stored as a Blob in a database... It's a
standard letter defined by the user.... The letter contains insertion codes
like <NAME>, <ADDRESS> , etc...  I use the mail merge function of my
reporting software to replace the insertion codes with the appropriate
information... but there is also a need for insertion codes like
<REPORTSUMMARY>... (actually, several different possible reports)... and I
need to be able to insert the "Report" which I have created in a richedit
component (not visible)... in place of the insertion code in the
standardized letter... and then perform the mailmerge and print...

I unload the standarized RTF letter file into a richedit (not visible) to
make my insertions (currently I'm using the "clipboard")... I'm just trying
to find a better way to make the insertions.

Joe Hutchins

"Peter Below (TeamB)" <100113.1...@compuXXserve.com> wrote in message
news:VA.00007cc5.00991855@antispam.compuserve.com...

Quote
> In article <3be74a58$1_2@dnews>, Joe Hutchins wrote:
> > I need to be able to search through a RTF file... looking for a
particular
> > "word"... and if found I need to replace the "word" with another RTF
file.

> Let's clear up a few things up front. Do you want to do that on *disk
files*,
> that is: not involving any visual component like a TRichedit? It can be
done,
> no question, but you need a very good understanding of the internal
structure
> of an rich text file to make this work. Or do you want to do this in a
rich
> edit control?

> Peter Below (TeamB)  100113.1...@compuserve.com)
> No e-mail responses, please, unless explicitly requested!
> Note: I'm unable to visit the newsgroups every day at the moment,
> so be patient if you don't get a reply immediately.

Re:Insert Rich Text into a Rich Text file


Quote
In article <3be9769a$1_1@dnews>, Joe Hutchins wrote:
> The RTF "file" I need to update is stored as a Blob in a database... It's a
> standard letter defined by the user.... The letter contains insertion codes
> like <NAME>, <ADDRESS> , etc...  I use the mail merge function of my
> reporting software to replace the insertion codes with the appropriate
> information... but there is also a need for insertion codes like
> <REPORTSUMMARY>... (actually, several different possible reports)... and I
> need to be able to insert the "Report" which I have created in a richedit
> component (not visible)... in place of the insertion code in the
> standardized letter... and then perform the mailmerge and print...

> I unload the standarized RTF letter file into a richedit (not visible) to
> make my insertions (currently I'm using the "clipboard")... I'm just trying
> to find a better way to make the insertions.

The PutRTFSelection function you probably got from an older post of mine
should work in this scenario. You use the FindText method of the richedit
holding the template to find the replacement tag, select it by setting
SelStart to the found location, SelLength to the length of the tag. Then you
load the report RTF into a stream, which class does not matter, you can use a
TStringstream or a TMemoryStream, whatever fits the source where the RTF
comes from. And then you call PutRTFSelection( theTemplaterichedit,
theRTFStream ).

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.

Other Threads