Accessing commandbarbutton at runtime

Add-in Express™ Support Service
That's what is more important than anything else

Accessing commandbarbutton at runtime
 
Lars Hjort


Guest


Is it possible to access an adxCommandBar from a windowsform window?

I would like to enable/disable a button in a commandbar from a form at runtime. Can it be done?


Thanks,

Lars Hjort
Posted 27 Jun, 2005 16:25:18 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Lars.

Yes, of course. You can use the CommandBarByName function of the AddinModule to access your command bar. To access a control on your command bar you can use the GetControlByTag or GetControlByControlTag functions of the ADXCommandBarControlCollection class (the Controls property of the ADXCommandBar component).
Posted 28 Jun, 2005 09:04:58 Top
Lars Hjort


Guest


If I try from a windows form with code like this:

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim addin As New AddinModule
        Dim ADXCommandBar As AddinExpress.MSO.ADXCommandBar
        Dim ADXCommandBarButton As AddinExpress.MSO.ADXCommandBarButton


        ADXCommandBar = addin.CommandBarByName("AdxCommandBar1")

        ADXCommandBarButton = ADXCommandBar.Controls.GetControlByControlTag("02273f8e-bb6b-48c8-a07b-9e7ac36b0a3e")

        ADXCommandBarButton.Enabled = True


    End Sub



It fails?Â?Ð??

/Lars
Posted 28 Jun, 2005 11:12:39 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Lars,
you can download an example here:
http://www.add-in-express.com/projects/myaddin4.zip
Posted 28 Jun, 2005 15:56:44 Top
Lars Hjort


Guest


Excellent. It works. Thanks a lot...

/Lars
Posted 01 Jul, 2005 06:58:04 Top