adding right click menu to textbox

×

×לי

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
 
R

Rick Rothstein \(MVP - VB\)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top