Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB5,VB6
Expertise: beginner
Oct 6, 2001

Let the user insert OLE objects in a RichTextBox control

A little-known feature of the RichTextBox control allows you to insert an OLE object in the text being edited. However, you can do so only programmatically, by adding an element to the OleObjects collection. An easy way to let the user select the object to be embedded in the control is using the InsertObjDlg method of the OLE Container object.

To test this functionality, drop a RichTextBox and an OLE control on a form (leaving their default names), add a cmdInsert button and write this code:


Private Sub cmdInsert_Click()
    ' Show the InsertObject dialog
    OLE1.InsertObjDlg
    If Len(OLE1.Class) Then
        ' If the user selected an object, show it in the RichTextBox control
        RichTextBox1.OLEObjects.Add , , , OLE1.Class
        OLE1.Class = ""
    End If
End Sub

Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date