The RichTextBox supports inserting both Images and Files. The following image formats are supported:
Bitmap (*.bmp)
Gif (*.gif)
JPEG (*.jpg)
It also supports
Word Documents (*.doc)
Excel Spreadsheets (*.xls)
Any other file will be displayed as an icon.
The following code shows a dialog to select a file, and then inserts the file into the RichTextBox
Sub Command1_Click()
With CommonDialog1
.CancelError = True
.Filter = "All Files *.*|*.*"
On Error Resume Next
' Show open dialog
.ShowOpen
If Err Then Exit Sub
End With
On Error Resume Next
' Attemt to add OLE Object
RichTextBox1.OLEObjects.Add , , CommonDialog1.Filename
' Check to see if an error has occured
If Err = 462 Then
MsgBox "Error importing file,
may be low on memory"
End If
End Sub
Comments