none
How should my Add-In keep track of the Worksheet tabs being clicked/selected by the user? RRS feed

  • Question

  • I have been developing this utility in parallel: as an Application-Level Add-In and as a Document-Level Customization.

    Theoretically, the latter is perfectly fitted, because the utility only makes sense in one very special worksheet.

    However, I have been persuaded to stay away from document-level and decided to emulate this feature, from my Add-In:

    In short, my Task Pane should become visible/invisible depending on the tab being clicked.

    Currently I can summon and dismiss the CustomTaskPane from a ToggleButton in a ribbon. This is very handy, but the mentioned, supplementary feature would be a very welcome addition.

    I have had minimal success, dealing with the canonical "Sheet1", "Sheet2" and "Sheet3", but when any real document/workbook is loaded the triggering events are lost.

    TIA


    Sunday, August 3, 2014 2:51 AM

Answers

  • Hi Travis Banger,

    Based on the description, you want to show the taskpane based on the active worksheet and set the property based on the visible of task pane.

    As Eugene mentioned we can use SheetActivate to change the visibility of the taskpane. Then we can in the VisibleChanged event to synchronize the ribbon control.

    Here is a article about Synchronizing a Custom Task Pane with a Ribbon Button for your rerence:
    Walkthrough: Synchronizing a Custom Task Pane with a Ribbon Button

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Travis Banger Thursday, August 14, 2014 2:50 AM
    Monday, August 11, 2014 7:41 AM
    Moderator

All replies

  • As long as we are on the topic, I would like to share with interested readers, the way to "untoggle" the ribbon button "from the inside" when the user closes the TaskPane by clicking on the "X" icon (See the point of the left red arrow in the original post).


    Sunday, August 3, 2014 3:17 AM
  • You may find the SheetActivate event of the Application and Workbook classes helpful. It is fired when any sheet is activated. An instance of the activated sheet is passed as a parameter to the event handler.
    Sunday, August 3, 2014 7:32 AM
  • Setting the Checked property is not a good idea. I'd recommend using the Ribbon callbacks instead. You can read about them in the following article in MSDN:

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)

    Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

    Sunday, August 3, 2014 7:38 AM
  • Setting the Checked property is not a good idea. 

    Why?

    Sunday, August 3, 2014 10:51 AM
  • The Ribbon UI is a static thing from its birth. The only possible dynamism is based on callbacks. Take a look at the articles I mentioned above for more information.
    Sunday, August 3, 2014 11:45 AM
  • The only possible dynamism is based on callbacks.

    Eugene: I already solved my problem, with code statements in many places and I am still not sure whether the bidirectionality between the "X" icon (*) and the toggle button is always maintained, in all scenarios.

    I am somewhat familiar with WPF+XAML and like the fact that all manipulations must be done to the underlying model, never in the GUI.

    Can I achieve that type of strong bidirectionality (BINDING) if I change my current (WinForm) code and use the ribbon?

    Thx

    (*) See OP.

    Sunday, August 3, 2014 2:41 PM
  • Hi Travis Banger,

    Based on the description, you want to show the taskpane based on the active worksheet and set the property based on the visible of task pane.

    As Eugene mentioned we can use SheetActivate to change the visibility of the taskpane. Then we can in the VisibleChanged event to synchronize the ribbon control.

    Here is a article about Synchronizing a Custom Task Pane with a Ribbon Button for your rerence:
    Walkthrough: Synchronizing a Custom Task Pane with a Ribbon Button

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Travis Banger Thursday, August 14, 2014 2:50 AM
    Monday, August 11, 2014 7:41 AM
    Moderator