ActionsPane AutoRecover and Clear

Misha Shneerson--also known as "Misha-Cat" and "founder of ActionsPane" recently answered some questions I had about ActionsPane. To preface this, VSTO's support for ActionsPane actually attaches a Smart Document solution to the Word or Excel document behind the scenes. This causes some issues you might run into. Here is our conversation more or less:

Eric: So the wacky AutoRecover property on ActionsPane--why would I ever not set it to true?

Misha: The AutoRecover property was added in response to some Word issues that would make Document Actions task pane go away under certain circumstances (e.g open View->Zoom dialog, click OK). Of course there are side effects of setting AutoRecover to true. Basically, end users will not be able to get rid of the Document Actions task pane if AutoRecover is set to true. Event if they go to the Tools->Templates and Add-ins->XML Expansion Packs dialog and detach the "Actions Pane" solution, the auto recovery will kick in and bring the Document Actions task pane back to life.

 

If you set ActionsPane.AutoRecover to true, the only way to get rid of the Document Actions task pane is by calling ActionsPane.Clear().

Eric: The Clear method--what does this do and what is the opposite of calling Clear--that is, after I call clear, how do I unclear?

Misha: ActionPanes.Clear just removes the ActionsPane smart document solution from the document. In Word, having an ActionsPane on the document also causes the ActionsPane.xsd schema be attached to the document. I tried to incorporate clearing the XSD from a Word document into the ActionsPane.Clear() method, but this caused crashes under some circumstances and I did not submit the fix at the end. In Excel, ActionsPane.Clear() completely removes all traces of the ActionsPane smart document solution, in Word we are left with the ActionsPane.xsd attached to the document--but this shouldn't cause any problems.

 

To bring the ActionsPane back (i.e. Unclear) user should just call ActionsPane.Show. This will reattach the smart document solution.

 

Usually people will want to call ActionsPane.Clear themselves when their customization starts up if their customization is not designed to show the Document Actions task pane from the beginning, but would rather be shown in response to a particular action. For such customizations, if the document is saved with the Document Actions task pane shown, then closed, when the document is reopened users will see a blank Document Actions task pane.

 

The solution here is to call ActionsPane.Clear on Startup or add controls to the ActionsPane on startup. If you call ActionsPane.Clear in Word at startup, this will also cause a dialog to pop up suggesting to attach ActionsPane XML Expansion Pack. To avoid this, ActionsPane.Clear should be followed by a call to Document.XMLReferences["ActionsPane"].Delete. The reason I did not special cases automatic inclusion of Document.XMLReferences["ActionsPane"].Delete into the ActionsPane.Clear() method is because of the crashing bug I mentioned above. Since we could not programmatically detect the condition under which crash would occur I decided to not special case calling ActionsPane.Clear on start up as well to avoid inconsistency in the behavior.