Click to See Complete Forum and Search --> : How to add command button to menu


naiiantopdog
May 25th, 2001, 12:14 PM
I need help adding a command button to a menu. I have a command button that when pushed it should open up a menu, and on the menu I need a command button to appear there. Could anyone help me? It would be much appreciated. Thanks

nederlof
May 25th, 2001, 04:40 PM
Something like this perhaps?

Dim CBCitem as CommandBarControl
set CBCitem = CommandBars("Tools").Controls.Add(Type:=msoControlButton, before:=3)
With CBCitem
.Caption = "Your &Text Here..."
.FaceId = 0
.OnAction = "YourSubHere"
End With



Or did you want something on a UserForm? In that case, the sub you refer to in OnAction should call YourForm.Show, assuming you have created the form and named it YourForm.