Disable certain control in a menu bar

  • Hi Guys,


    I have a Add in that creates a custom menubar .. I need to disable only a certian control in my custom menubar.


    I used the following line

    Code
    ' The Tag refers to a Commandbar control that opens a new report.
    Application.CommandBars.FindControl(Tag:="GRNew Report").Enabled = False


    This however is not disabling my New report commandbar button ...
    I have also tried the following approach ..

    Code
    Dim temp as variant
    Set temp = CommandBars.FindControl(Type:=msoControlPopup, Tag:="GRNew Report")
    temp.enabled = false


    The findcontrol method works fine & returns proper control .. but the Enabled property is not working !!! Please help , this is driving me crazy !!

  • Re: Disable acertain control in a menu bar


    can you show us the code that made this GRNew Report copmmandbar in the first place?

    Cheers
    ___________
    Xlite :sheep:
    [st]All you need to learn VBA is an internet connection and Ozgrid.com[/st]

  • Re: Disable acertain control in a menu bar


    Maybe you require this...


    Code
    Application.CommandBars("GRNew Report").Enabled = False


    HTH
    ilyaskazi


    Nope, this work only if your cmdbar name is as above and not tag. sorry.
    ilyaskazi.

  • Re: Disable acertain control in a menu bar


    Here's the code that created the custom menubar.


    Also i just noticed that , the

    Code
    Application.CommandBars.FindControl(Tag:="GRNew Report").Enabled = False


    is not working ONLY for new report control ... It's working fine for "Requery & Calculate " when I change the tag property to GRRequery And Calculate .... This is all the more frustrating !

  • Re: Disable acertain control in a menu bar


    try this one:

    Code
    Sub disableNReport()
    Application.CommandBars(1).Controls("&Global Reporting") _
    .Controls("&New Report...").Enabled = False
    End Sub

    Cheers
    ___________
    Xlite :sheep:
    [st]All you need to learn VBA is an internet connection and Ozgrid.com[/st]

  • Re: Disable certain control in a menu bar


    All ..

    Thank you very much ... Currently, I am using the method as referrred by xlite which works as an alternative ... I will try disbaling with the using the ID property & chekc if it works ... Many thanks again for all your help.

    Rgds
    Tausif

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!