PDA

View Full Version : right click menu in a text box



dpark
01-04-2007, 08:21 PM
I have a textbox and i want to be able to paste, copy, and cut text into and from this textbox. I know it should use the basic mouse down and mouse up commands but i dont have a clue how to add these three options.
So far all i have is what you see below. It will show the button clicked in textbox2 and clear textbox2 when i right click in textbox1. Any help would be appreciated Thanks.

Private Sub TextBox1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If Button = 2 Then
TextBox2.Text = Button

Else
End If
End Sub
Private Sub TextBox1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
TextBox2.Text = ""
End Sub

lucas
01-04-2007, 09:25 PM
Close but you need to call the rightclick menu and call a macro that runs the keypress. Too much to post code so I will attach a simple example that you can look at to answer most of your questions

dpark
01-05-2007, 09:11 PM
Thanks Lucas

Thats the right menu, but i dont want a userform. Is it possible to do that menu directly on a textbox in the main sheet of an excel work book? I was also wondering where i can find a list of the control items that I can put in the menu. I would like to have a clear all and a select all option as well.

Thanks again for your help

lucas
01-05-2007, 09:35 PM
What do you mean by clear all.....clear contents?

lucas
01-05-2007, 10:06 PM
You can run any macro this way.....it's better to copy the code and paste into a new workbook each time as it doesn't delete the old menu when it closes....

tstom
01-05-2007, 10:10 PM
This example from this post at mrexcel should be adaptable to work with worksheet controls. Currently it is written for controls on a userform...

File
http://home.fuse.net/tstom/Textbox_ComboBox_ContextMenuExample.zip

Post
http://www.mrexcel.com/board2/viewtopic.php?p=1093738#1093738