Add Command to RightClick Menu

G

Guest

I have a real simple routine that use to add a new command to the RightClick
Menu.

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

But for some reason, now it does not work. Nothing is add to the RightClick
menu. What I want is "Remove" added to the menu and when clicked, for it to
run the macro "Remove".

Two, can I add other commands with "Sub CreateRightClick2()". I have only
added one command before.


Any Help is Always Appreciated.
 
B

Bob Phillips

I don't know why it didn't work. maybe there was an error in the runcode.
Have you tried stepping through it? Does Remove already exist on the menu.

You can add m ultiples like so

Sub CreateRightClick()
With Application.CommandBars("Cell")
With .Controls.Add
.Caption = "Remove"
.OnAction = "Remove"
End With
With .Controls.Add
.Caption = "Remove2"
.OnAction = "Remove2"
End With

End With
End Sub
 
G

Guest

Ronbo said:
I have a real simple routine that use to add a new command to the RightClick
Menu.

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

But for some reason, now it does not work. Nothing is add to the RightClick
menu. What I want is "Remove" added to the menu and when clicked, for it to
run the macro "Remove".

Two, can I add other commands with "Sub CreateRightClick2()". I have only
added one command before.


Any Help is Always Appreciated.

Never mind. I got it and it works fine.
 
G

Guest

Bob Phillips said:
I don't know why it didn't work. maybe there was an error in the runcode.
Have you tried stepping through it? Does Remove already exist on the menu.

You can add m ultiples like so

Sub CreateRightClick()
With Application.CommandBars("Cell")
With .Controls.Add
.Caption = "Remove"
.OnAction = "Remove"
End With
With .Controls.Add
.Caption = "Remove2"
.OnAction = "Remove2"
End With

End With
End Sub


--
HTH

-------

Bob Phillips

Thanks Bob. You are right it was a simple error in the code that I check over and over and did not find until after the post. However, I like and use your multiple commands.
 

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