• Intercepting CTRL-v before RichTextBox Paste (VB)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Intercepting CTRL-v before RichTextBox Paste (VB)

    Author
    Topic
    #382571

    I have learned that the RichTextControl supports CTRL-v, Shift-Insert, Drag/Drop, and other when pasting data. My goal is to pre-process the pasted data and not have it go directly into the RichTextBox document. I have tried to use the Form_KeyDown event with no results- i suspect that CTRL-v is a windows thing. I might have to use a combination of APIs functions to do what i want. Has anybody solved this problem? Any suggestions on how i should tackle this?

    Thank you,

    –Llyal

    Viewing 0 reply threads
    Author
    Replies
    • #649054

      Both the KeyDown and the Key Press fire, but the paste occures between them. So to change the behavior of Ctrl+V, use the KeyDown. Here is an example which disables Ctrl+V: HTH –Sam

      Option Explicit
      Private Sub RichTextBox1_KeyDown(KeyCode As Integer, Shift As Integer)
          If KeyCode = vbKeyV And Shift = vbCtrlMask Then
              Debug.Print "Down"
              KeyCode = 0
          End If
      End Sub
    Viewing 0 reply threads
    Reply To: Intercepting CTRL-v before RichTextBox Paste (VB)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: