?
Solved

Inserting text from another file into a point in a RichText control

Posted on 2005-03-10
1
Medium Priority
?
216 Views
Last Modified: 2010-05-02
I would like to be able to position the cursor at a certain point and then by right clicking choose "insert" and open a file and copy its contents into the RTF control at that point.
0
Comment
Question by:garyLittle
1 Comment
 
LVL 32

Accepted Solution

by:
Erick37 earned 1000 total points
ID: 13507371
Following assumes:
CommonDialog control: cdlg
Richtextbox control: RichTextBox1
Menu Items for the popup menu: mnuPop->mnuInsert


Option Explicit



Private Sub mnuInsert_Click()
   
    On Error GoTo ERR_CANCEL
   
    Dim sInsert As String
   
    'CommonDialog control named cdlg
    cdlg.CancelError = True
    cdlg.Filter = "Text (*.txt)|*.txt"
    cdlg.Flags = cdlOFNFileMustExist
    cdlg.InitDir = "c:\"
    cdlg.ShowOpen
   
    Open cdlg.FileName For Binary As #1
    'make room for the contents
    sInsert = Space(LOF(1))
    'get the data
    Get #1, , sInsert
    Close #1
   
    'paste the contents
    RichTextBox1.SelText = sInsert
   
    Exit Sub
ERR_CANCEL:
   
   
End Sub

Private Sub RichTextBox1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = vbRightButton Then
        PopupMenu mnuPop
    End If
End Sub
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month3 days, 13 hours left to enroll

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question