Add Command to Right-Click Menu

A

Andy

I know how to add a macro to the right-click context menu, for example
to add the macro PasteVal:

Sub CreateRightClick()
With Application.CommandBars("Cell").Controls.Add
.Caption = "Paste Values"
.OnAction = "PasteVal"
End With
End Sub


How would I add a conventional command to the right-click menu? Is it
just a question of knowing the exact name of the command? I'm
particularly interested in adding "Conditional Formatting..." to my
right-click menu.

TIA,


Andy
 
E

Edwin Tam

Try the extended macros below:

Sub CreateRightClick()
With Application.CommandBars("Cell").Controls.Add
.Caption = "Conditional Formatting..."
.OnAction = "show_cf"
End With
End Sub

Private Sub show_cf()
Application.Dialogs(xlDialogConditionalFormatting).Show
End Sub

Regards,
Edwin Tam
(e-mail address removed)
http://www.vonixx.com
 
S

Shailesh Shah

Hi Andy,

Using Command's ID for Conditional formatting.

Sub CreateRightClick()
With Application.CommandBars("Cell").Controls
.Add Type:=msoControlButton, _
ID:=3058, _
temporary:=True
End With
End Sub


Regards,
Shah Shailesh
http://members.lycos.co.uk/shahweb/
 

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