View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Kent McPherson Kent McPherson is offline
external usenet poster
 
Posts: 15
Default New menu item action

I have a menu item added to the Tools menu called MyMenu. I'm trying to tie
it to a VBA subroutine I've written called MySub. I have this code for the
menu.

Application.CommandBars("Worksheet menu
bar").Controls("Tools").Controls.Add(Type:=msoCont rolButton).Caption =
"MyMenu"
Application.CommandBars("Worksheet menu
bar").Controls("Tools").Controls("MyMenu").OnActio n = MySub

Then I created a new module with this code.

Private Sub MySub ()

MsgBox ("My subroutine")

End Sub

When I select the MyMenu command from the Tools menu, nothing happens so I'm
obviously not making the linkage correctly. Any help would be greatly
appreciated.