Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding a right-click context menu to Excel VBA TextBoxes

Hello All,

I am created text boxes using
views--Toolbars----control toolbox in excel.

I need VBA code for right mouse button to copy, paste,delete and select
all options.

Could some one help me above situation.

Thanks,
Ram


*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Adding a right-click context menu to Excel VBA TextBoxes

Ram

Add this code into the code module for the worksheet that contains the
textbox. To do this, right-click the tab of the worksheet with the textbox
and choose "View Code" and then paste the code into the module. Change the
name of the textbox to match yours:

Private Sub TextBox1_MouseUp(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If Button = vbKeyRButton Then
Call MakeMenu
Application.CommandBars("TextBox Bar").ShowPopup
End If
End Sub

Sub MakeMenu()
Dim cbTextBox As CommandBar
Dim cmdTest As CommandBarButton

'in case it already exists
Call DeleteBar
Set cbTextBox = CommandBars.Add(Name:="TextBox Bar", Position:=msoBarPopup,
temporary:=True)
With cbTextBox
Set cmdTest = .Controls.Add(Type:=msoControlButton, temporary:=True)
With cmdTest
.Style = msoButtonIconAndCaption
.FaceId = 3
.Caption = "test"
.OnAction = "TestRoutine"
End With
End With
End Sub

Sub DeleteBar()
'in case it doesn't exist
On Error Resume Next
CommandBars("TextBox Bar").Delete
End Sub

Then in a regular module, add this code. This is the subroutine that's
named in the OnAction property of the button. This is just an example:

Public Sub TestRoutine()
MsgBox "Test Pressed!"
End Sub

hth,

Doug

"ram gopal" wrote in message
...
Hello All,

I am created text boxes using
views--Toolbars----control toolbox in excel.

I need VBA code for right mouse button to copy, paste,delete and select
all options.

Could some one help me above situation.

Thanks,
Ram


*** Sent via Developersdex http://www.developersdex.com ***



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding commands to the Excel 2007 Chart context menu Andreas Charts and Charting in Excel 1 January 23rd 09 08:15 PM
Undo button in the context menu (right click menu) Madiya Excel Programming 7 April 7th 08 04:33 PM
Custom Context menu (Right click menu) not working in sheet changeevent. Madiya Excel Programming 3 February 11th 08 01:24 PM
Adding context menu to shapes in Excel 2007 JJ Excel Programming 0 June 2nd 07 12:28 PM
Right-Click (Context Menu) Kryptonix Excel Programming 6 October 25th 05 03:59 PM


All times are GMT +1. The time now is 01:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"