visual basic code:
Dim iPos As Long
Dim strInsert As String
Dim strRTF As String
Dim lStart As Long
'assumes that strInsert contains the RTF code that you want to insert
'and that the current cursor position is where you want it selected
With RichTextBox1
'mark the current insertion point with special characters
.SelText = Chr(&H9D) & Chr(&H81)
'get the rtf text into our variable
strRTF = .TextRTF
'insert our text at the insertion point
strRTF = Replace(.TextRTF, "\'9d", strInsert)
.TextRTF = strRTF
'now find the end of the insertion
lStart = .Find(Chr(&H81))
'get rid of the other character
strRTF = Replace(.TextRTF, "\'81", "")
.TextRTF = strRTF
'position the cursor after the insertion
.SelStart = lStart
End With
Dim strInsert As String
Dim strRTF As String
Dim lStart As Long
'assumes that strInsert contains the RTF code that you want to insert
'and that the current cursor position is where you want it selected
With RichTextBox1
'mark the current insertion point with special characters
.SelText = Chr(&H9D) & Chr(&H81)
'get the rtf text into our variable
strRTF = .TextRTF
'insert our text at the insertion point
strRTF = Replace(.TextRTF, "\'9d", strInsert)
.TextRTF = strRTF
'now find the end of the insertion
lStart = .Find(Chr(&H81))
'get rid of the other character
strRTF = Replace(.TextRTF, "\'81", "")
.TextRTF = strRTF
'position the cursor after the insertion
.SelStart = lStart
End With