Thursday, May 25th, 2006

VSTO – ActionsPane.Clear causes ExpansionPack dialog to pop up



Eric Carter appears to be the only one who has blogged on the problem with ActionPanes.Clear presenting the user with an XML Expansion Pack dialog.

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.

I had the same problem but could not find the method Document.XMLReferences[....].Delete I did however solve the problem with thefollowing code

Word.XMLSchemaReference apSchema = null;
foreach (Word.XMLSchemaReference schema in                    
this.XMLSchemaReferences)
{

if (schema.NamespaceURI == “ActionsPane”)
{
apSchema = schema;

break;
}
}

if (apSchema != null) apSchema.Delete();

blog comments powered by Disqus