Right click menus

C

Chip Pearson

You can use code similar to the following.


Sub CreateMenuItem()
Dim RCMenu As Office.CommandBar
Dim Ctrl As Office.CommandBarButton
Set RCMenu = Application.CommandBars("Cell")
Set Ctrl = RCMenu.Controls.Add(Type:=msoControlButton, temporary:=True)
With Ctrl
.BeginGroup = True
.Caption = "Click Me"
.OnAction = "'" & ThisWorkbook.Name & "'!RunProc"
End With
End Sub

Sub RunProc()
MsgBox "hello world"
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
G

Guest

Yes that does somthing along the right lines. I am a novice with code and
want to add "Paste Values" to a right click.
I was hoping to just be able to just add it to the right-click menu in much
the same way as you add things to the toolbars but I presume this is not
possible.
 
C

Chip Pearson

Use code like

Sub AAA()
Application.CommandBars("Cell").Controls.Add ID:=370, temporary:=True
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
G

Guest

Thanks that works fine!

Chip Pearson said:
Use code like

Sub AAA()
Application.CommandBars("Cell").Controls.Add ID:=370, temporary:=True
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 

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