ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating right-click menus (https://www.excelbanter.com/excel-programming/375882-creating-right-click-menus.html)

HappyInUtah

Creating right-click menus
 
I have an excel worksheet with multiple text boxes. I want to create a
right-click menu that will allow me to select "copy" or "paste", just like
you can do in MS Office apps. My idea (as I am not an accomplished VB
programmer) is to create a list box that is called on right mouse button
click. Where do I go from there?
Here is what I have so far...

Private Sub TextBox11_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)

If Button = 1 Then
Me.Label10.Visible = True
ElseIf Button = 2 Then
Me.ListBox1.Visible = True
Else: End If

End Sub

Private Sub TextBox11_MouseUp(ByVal fmButtonLeft As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)

Me.Label10.Visible = False

End Sub

Where...Label10 is just a tooltip, and TextBox1 is my box containing "Copy"
and "Paste". Also, can I make the listbox position variable based on cursor
position?
Thanks for any help.

HappyInUtah

Creating right-click menus
 
I am also considering using a form instead of the listbox. The form would
have two control buttons. One would use the Clipboard.SetText function and
the other would use the Clipboard.GetText function. Does this sound viable?

"HappyInUtah" wrote:

I have an excel worksheet with multiple text boxes. I want to create a
right-click menu that will allow me to select "copy" or "paste", just like
you can do in MS Office apps. My idea (as I am not an accomplished VB
programmer) is to create a list box that is called on right mouse button
click. Where do I go from there?
Here is what I have so far...

Private Sub TextBox11_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)

If Button = 1 Then
Me.Label10.Visible = True
ElseIf Button = 2 Then
Me.ListBox1.Visible = True
Else: End If

End Sub

Private Sub TextBox11_MouseUp(ByVal fmButtonLeft As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)

Me.Label10.Visible = False

End Sub

Where...Label10 is just a tooltip, and TextBox1 is my box containing "Copy"
and "Paste". Also, can I make the listbox position variable based on cursor
position?
Thanks for any help.



All times are GMT +1. The time now is 03:03 AM.

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