ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   adding right click menu to textbox (https://www.excelbanter.com/excel-programming/392497-adding-right-click-menu-textbox.html)

אלי

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

Rick Rothstein \(MVP - VB\)

adding right click menu to textbox
 
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


Michel Pierron

adding right click menu to textbox
 
Hi Eli,
An example here
http://cjoint.com/?hcqjbyrlKZ

Regards
MP

"???" a crit dans le message de news:
...
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




אלי

adding right click menu to textbox
 
Rick and Michel
Thanks for your help, it works like a dream.

Eli

"Michel Pierron" wrote:

Hi Eli,
An example here
http://cjoint.com/?hcqjbyrlKZ

Regards
MP

"???" a écrit dans le message de news:
...
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






All times are GMT +1. The time now is 05:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com