Consulting

Results 1 to 3 of 3

Thread: How to enable right click paste on more than one TextBox

  1. #1
    VBAX Mentor
    Joined
    Aug 2020
    Location
    Hampshire
    Posts
    395
    Location

    How to enable right click paste on more than one TextBox

    As kindly provided by Graham Mayor on a separate thread, I've been using the following attached to enable right mouse click pasting into a TextBox, using the below Sub to enable pasting, in this case, into the TextBox labelled txtEditor.

    Private Sub txtEditor_MouseDown(ByVal Button As Integer, _
            ByVal Shift As Integer, _
            ByVal x As Single, _
            ByVal y As Single)
    
        ' If right-button clicked
        If Button = 2 Then
            Call ShowPopup(Me, Caption, txtEditor, x, y)
        End If
        
    lbl_Exit:
        Exit Sub
    End Sub
    This works brilliantly on a single Textbox, but I was wondering how one would be able to utilize it for more than one TextBox on the same UserForm. I can add multiple Subs and changing the Sub name and related TextBox name, but was wondering if there was a more efficient way?
    Attached Files Attached Files

  2. #2
    Use multiple subs.

    Private Sub TextBoxName_MouseDown(ByVal Button As Integer, _
            ByVal Shift As Integer, _
            ByVal x As Single, _
            ByVal y As Single)
    
        ' If right-button clicked
        If Button = 2 Then
            Call ShowPopup(Me, Caption, TextBoxName, x, y)
        End If    
    lbl_Exit:
        Exit Sub
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    VBAX Mentor
    Joined
    Aug 2020
    Location
    Hampshire
    Posts
    395
    Location
    Thanks Graham, I thought that might be the case, but thought that I would ask just in case.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •