Click to See Complete Forum and Search --> : Rich Text Control (RTF)


pmott
February 17th, 2000, 02:50 AM
"mypic.bmp" is a bitmap file. rtfMyText is a rich text box. It is filled with text. I do this:

x = rtfMyText.SelStart
rtfMyText.InsertOleObjectAt x, "myPic.bmp"

but alas the picture is not inserted into the rich text box after all. Indeed I don't even know andcannot find out how to insert a string in the box:

x = rtfMyText.SelStart
rtfMyText.InsertStringAt x, "Hello world!"

Anyone have any ideas on this?

Thanks,

Peter

Ravi Kiran
February 17th, 2000, 03:45 AM
For "InsertStringAt" , you can use

.SelText = NewTextString
To insert ole objects, i am checking how to do. will post it here, if i can find.

RK

Ravi Kiran
February 17th, 2000, 04:18 AM
This thing works for inserting the bmp pictures into RTB. Check it out:

Take one form. put one RTB.
Change the szfilename to valid file on your system and run

option Explicit

private Sub Form_Click()
RichTextBox1.SelStart = 3
RichTextBox1.SelText = "[new hi there]"
End Sub

private Sub Form_DblClick()
Dim lpobj as OLEObject
Dim szfilename as string
szfilename = App.Path & "\ttt444.bmp" ' put some valid file name here
set lpobj = RichTextBox1.OLEObjects.Add(, , szfilename)
lpobj.DisplayType = rtfDisplayContent
' if you un comment the following line you will go to edit mode:
'lpobj.DoVerb
End Sub

private Sub Form_Load()
me.RichTextBox1.Text = "Hi there"
End Sub





RK