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!

RTF :inserting text by code 1

Status
Not open for further replies.

andrewlee

Programmer
May 28, 2000
31
NZ
Hi All

I'm trying to insert some text programatically into an OLERichText object. I can do this by manipulating the text property, but cannot do it using the testrtf property. Using just the text property reduces the whole contents to plain text. Specifically, I want to insert a header (Bold and Underlined) to existing text then leave the user free to type text underneath. I can't get the Upto, Span,SelBold or SelUnderline Properties/Methods to work. Does anyone know where I can find out what parameters some of these properties expect ?
Cheers
Andrew
 
Hi!

Take a look to SelStart/SelLength properties. Remember current insertion point if needed. Set the insertion point to required place using just plain characters from the Text property. Then assign text required to insert to the SelRTF property or to the SelText property depended on the type of the text you want to insert (formatted or plain text). You can set up before inserting by SelText the SelBold and similar settings, so inserted text will have required RTF formatting.
Well, when you need to insert text with mixed bold and other settings, you can do it by 2 ways.
You can prepare text with RTF tags and just assign it to the SelRTF. RTF tags you can see when you look to the memo field edited by the RTF control - this way you will be able easy see tags formats.
You can also put a second hidden RTF control, using its SelText and SelBold + similar properties prepare the RTF text in it, then using its TextRTF property get the RTF text and assign it to the visible control's SelRTF property.

Hope this helps. Vlad Grynchyshyn, MS MVP, MCP
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Hi Vlad

Many, many thanks. It works fine now

Cheers

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top