Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rich Text concatenation 1

Status
Not open for further replies.

AndrewMurn

Programmer
May 9, 2001
4
AU
I wish to append rich text from a RichTextBox to an RTF file. How do I do that?

The method that I thought of was to load some RTF into one RichTextBox, and then to concatenate the new RichText to that, then save to the RTF file.

I can drag and drop the rich text without a hassle, but I am unable to copy rich text using either:

B$ = RTB.Text or B$ = RTB.TextRTF

Nor can I use get/set clipboard. Either method simply adds normalised text to the RichTextBox. TextRTF adds the "source code" if you will, but that's not what I'm wanting to do.

I don't want to use drag and drop, because it should be able to be automated. Shouldn't it?

I can't help feeling that I'm overlooking something obvious. Surely I'm not the first person to want to do this.

Andrew
 
Try using .SelStart = 1, .Sellength = 99999999 and then use .SelRTF. I can't guarantee waht happens to font and color. The problem is that all the font/color info is in a header at the beginning of the RTF and strict concatenation doesn't "merge" all the info.
 
Thankyou for the attempt, John. Unfortunately this suggestion with .selstart=0 and .selstart=1 resulted in plain "source" text only.
 
Damn! I'm stupid. I've never noticed the .SelRTF before, and used .SelText and .TextRTF thinking you'd made an error. Once I tried .SelRTF, it worked.

For those interested:
'I want to add something to the end of RTB1.Text,
'so find the end of that text.
RTB1.SelStart = Len(RTB1.Text)

'Now select all of the rich text in RTB2 ...
RTB2.SelStart = 0
RTB2.SelLength = Len(RTB2.Text)

'... and add it to RRTB1
RTB1.SelRTF = RTB2.SelRTF

 
Well thanks for the honesty. I've been programming, not just coding, for 36 years, right out of high school and among the many things I've found necessary to become an excellent progammer, the most necessary has been the cognition that "sometimes, maybe just for a couple of moments, I am the stupidest person on the face of the earth". After that it takes less and less time to RE cognize that it just might be happening again and recover.
 
36 years?? Well that explains it! I didn't start programming till a year later (1966).

And I still make dumb errors. But as long as I learn from them..... *grin*
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top