Add Command to RightClick Menu

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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
 
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.
 
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.
 
Back
Top