Toolbar buttons getting disabled

Hi,

I developed an addin and added a toolbar to it (Visual Studio 2003). The toolbar is instantiated in the CConnect::OnConnection(...) function. Everything works fine and the toolbar is visible, however all buttons of the toolbar are disabled. I have tried various things to enable them but to no avail. I have tried using Office::CommandBar::put_Enabled(...) (for the entire menu) property and Office::CommandBarControl::put_Enabled(...) (for each individial control bar item) property.

Any help will be highly appreciated.

P.S. I have noticied that people usually answer questions related to VS 2005. Is it true or just my feeling



Answer this question

Toolbar buttons getting disabled

  • Rick Potts - MSFT

    If you are using CommandBarControls.Add(...) to add your controls, this is not the suggested method. The new method, Commands.AddNamedCommand is the better way. This method fixes a lot of the problems with the office model, such as if a user customizes command then the event handler is lost, and the command can be run from the command window. It also has some performance benefits, such as JIT activation of our Add-in if the command is executed, and the command is persisted across instances of VS. You can run the Add-in wizard and check the "Create a tools menu item" to create the command for you.

    If you really need to use the old way, and it is no longer working, reopen this post and we will try to figure it out.

    Craig



  • Toolbar buttons getting disabled