Word Task Panes - controlling visibility and passing state

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

Word Task Panes - controlling visibility and passing state
 
letdowncrush




Posts: 13
Joined: 2018-06-14
Hi

I've gone through the documentation and been through various samples (e.g. ContextDependentAETPvs2005cs) and can't seem to find a consistent / clean way of managing the visibility of task panes and passing contextual state to them.

Test Scenario:

I would like *all* task panes to be inactive / hidden (whichever is most appropriate) until a user performs a particular action, for example, focuses on a content control and then I would like to choose a particular task pane to show based on some logic and pass contextual data to that pane.

Issues:

The task pane(s) are active / visible by default.

There are a number of different events you can handle:

- ADXAddinModule.OnTaskPaneBeforeShow - I subscribed to this event, but it doesn't seem to fire.
- ADXWordTaskPanesManager.ADXBeforeTaskPaneInstanceCreate - I can hide the task panes by setting e.Cancel = true
- ADXWordTaskPane.ADXBeforeTaskPaneShow - I can hide a specific task pane by setting Visible = true

Is there any documentation or guidance on which one you should use and for what purpose?

What is the best approach for my scenario?

I've tried, for example, setting Visible = false when subscribing to the before show event on the task pane itself, but if you later set it to true or call Show() or even Activate(), it never seems to display.
Posted 19 Jun, 2018 07:15:46 Top
Andrei Smolin


Add-in Express team


Posts: 16662
Joined: 2006-05-11
Hello,

Add-in Express supports two different pane systems:
- Custom Task Panes by Microsoft; it is available through the TaskPanes collection and TaskPane-related event on the add-in module
- Advanced Task Pane by Add-in Express; ContextDependentAETPvs2005cs highlights using this approach.

An Add-in Express pane is shown whenever the context matches the settings. In case of Excel, this occurs whenever an Excel window is shown. You can prevent an ADX*TaskPane from being shown by setting ADXExcelTaskPane.Visible = false in the ADXExcelTaskPane.ADXBeforeTaskPaneShow event.

letdowncrush writes:
I would like *all* task panes to be inactive / hidden (whichever is most appropriate) until a user performs a particular action, for example, focuses on a content control and then I would like to choose a particular task pane to show based on some logic and pass contextual data to that pane.


To achieve this, you can have a flag - e.g. a public Boolean property deaclared on the add-in module so that the pane class(es) read that property in the ADXBeforeTaskPaneShow event and set ADXExcelTaskPane.Visible accordingly. Then you set the flag to "let paneinstances show", scan ADXExcelTaskPanesCollectionItem.TaskPaneInstances and call ADXExcelTaskPane.Show; this triggers ADXBeforeTaskPaneShow, your panes read that flag and thus your panes get shown.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 20 Jun, 2018 04:17:01 Top