Disable submenu Menu-Menu1-Function2

SlepyJack

New member
Local time
Today, 19:33
Joined
Oct 21, 2004
Messages
6
I created menu:

Private Sub CreateMenu()
Dim MenuCb As CommandBar: Dim MenuCbc As CommandBarControl: Dim MenuCmcp As CommandBarControl

'Main Menu Bar
Set MenuCb = Application.CommandBars.Add("MyMenu", msoBarTop, True, False)

'Menu of Main Menu Bar
Set MenuCbc = MenuCb.Controls.Add(msoControlPopup)
MenuCbc.Caption = "MyMenu1"

'Submenu of Menu of Main Menu Bar
Set MenuCmcp = MenuCmc.Controls.Add(msoControlButton)
MenuCmcp.Caption = "Function1": MenuCmcp.Style = msoButtonCaption: MenuCmcp.OnAction = "RunFunction1"
Set MenuCmcp = MenuCmc.Controls.Add(msoControlButton)
MenuCmcp.Caption = "Function2": MenuCmcp.Style = msoButtonCaption: MenuCmcp.OnAction = "RunFunction2"

MenuCm.Visible = True

End Sub


My question:

How Can I by VB Disable submenu MyMenu-MyMenu1-Function2 ?

Sub DisableFunction2 ()
?
?
?
End Sub
:mad:
 
Use the FindControl method of the CommandBar object, which returns a CommandBarControl object, which you can disable. You may need to add a .Tag value to your control when you create it, since the FindControl method does not appear to be able to search for the .Caption of a control.
 
Yes !
Thank you for your Help.
 

Users who are viewing this thread

Back
Top Bottom