15

I'm trying to add a Custom Task Pane in an Excel Add-in which is intended to work similarly to the Pivot Tables pane.

The intention is that when a Table is selected the custom pane should appear and should disappear. To do this, I've created a custom task pane:

this._taskPane = Globals.AddIn.CustomTaskPanes.Add(
    new TableTaskPane(),
    "FooPane");
this._taskPane.DockPositionRestrict
    = MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoHorizontal;

When the table is selected the pane is made visible, and when deselected the pane is hidden:

ListObject table = AddTable(); // Creates the table and populates with data.

table.Selected += range => this._taskPane.Visible = true;
table.Deselected += range => this._taskPane.Visible = false;

This achieves the effect of showing and hiding the pane, but unfortunately generates some lag in the UI, where the cursor "bounces" between the cells as the task pane transitions between visibility states.

This seems to be because the setter of the Visible property blocks until the Task Pane completes the transition. In Excel 2013, it slides out from the side of the window, which takes around 500ms.

I can't see any way to change this behaviour - I've tried scheduling the property-setting on the STA Thread, but it causes the same blocking. I'd be happy to change the Task Pane so that it just appears immediately without the transition (like the Pivot Table pane), but I don't see anything to make that happen either.

Am I doing this incorrectly? Is there a way to fix this with direct COM or some other subtly-hidden behaviour?

Paul Turner
  • 38,949
  • 15
  • 102
  • 166
  • 2
    Hey, did you solve the problem? If so, could you post an answer? Many thanks. – Luca Martini Apr 03 '14 at 11:54
  • 1
    Not really what you're looking for, and it's a global change for all of Office 2013, and also it requires a reboot so you can't do it inside your addin temporarily, but you can disable the animations altogether with a registry change: [HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Common\Graphics] "DisableAnimations"=dword:00000001 – ReturningTarzan Sep 20 '15 at 19:47
  • "I'd be happy to change the Task Pane so that it just appears immediately without the transition (like the Pivot Table pane), but I don't see anything to make that happen either." - You can disable animation of custom task panes with a registry change (DisableWindowTransitionsOnAddinTaskPanes) thus removing the 500 ms lag. Please see my [answer](https://stackoverflow.com/questions/39857254/slide-animation-when-showing-hiding-customtaskpane-in-vsto/48260328#48260328) for details. – Vladimir Krilov Jan 21 '18 at 09:20

2 Answers2

1

You should be able to set the width of the pane to zero either through the Pane API or failing that use the Windows API SetWindowPos. Then change the visibility. I don't use VSTO but know it can be done using the raw Office Pane objects.

Neal
  • 11
  • 1
  • 1
0

You can accomplish this (and even more performance improvements) by turning off silly windows animation features found here: Control Panel -> System and Security -> System -> Advanced Settings -> Performance Settings -> Visual Effects.

In this particular case, I believe you need to turn off this one:

  • Animate controls and elements inside windows.

But these are also great for speeding things up:

  • Fade or slide menus into view
  • Slide open combo boxes
  • Animate windows when minimizing and maximizing.
Josh Fierro
  • 140
  • 10
  • 1
    I don't think I'll have much luck in persuading all my customers to downgrade their entire visual experience just to make my add-in work better, but I appreciate this may be the only actual solution to the problem. – Paul Turner Oct 01 '15 at 16:28