This example saves the highlighted contents of a RichTextBox control to an .rtf file. To try this example, put a RichTextBox control and a CommandButton control on a form. Paste this code into the Click event of the CommandButton control. Then run the example.
Private Sub Command1_Click ()
Open "mytext.rtf" For Output As 1
Print #1, RichTextBox1.SelRTF
Close 1
End Sub