adding right click menu to textbox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have assigned a "cell' menu to a textbox (in a userform) under the
dblclick event in order to copy and paste from and to the textbox. The
problem is that the pasted information is going to the active cell in the
worksheet instead of the userform's textbox.
Why there is no right click event for a textbox? and how can i paste the
information straight to the textbox?

Thanks in advance to your suggestion

Eli
 
I have assigned a "cell' menu to a textbox (in a userform) under the
dblclick event in order to copy and paste from and to the textbox. The
problem is that the pasted information is going to the active cell in the
worksheet instead of the userform's textbox.
Why there is no right click event for a textbox? and how can i paste the
information straight to the textbox?

While there is no "Right Click" event for a TextBox on a UserForm, you can
make use of the MouseDown or MouseUp events to see if the Right or Left
mouse buttons were pressed and put code in these tests to react to the
appropriate mouse button click. Here is a simple example to show this...

Private Sub TextBox1_MouseUp(ByVal Button As Integer, ByVal Shift As
Integer, _
ByVal X As Single, ByVal Y As Single)
If Button = xlSecondaryButton Then
MsgBox "RIGHT mouse button was pressed"
ElseIf Button = xlPrimaryButton Then
MsgBox "LEFT mouse button was pressed"
End If
End Sub


Rick
 
Back
Top