1

My problem is probably best described in this question: Auto-opening side-loaded taskpane But, the answer given won't work for me. I work at a company and setting up a new PC is not an option.

I wrote an Office (Word) Add-In (Office API/JS) and I want it to auto-open when a user opens one of the documents listed on my website. When a user selects a document to download, I open the document on the web server before downloading it and add some extra OpenXML parts in the document using OpenXML to make it open the Add-In. Here's the code:

//params: 
// wordDoc - the WordProcessing object being updated
//_WebExtensionStoreReferenceId = GUID of Add-In (the <Id> tag in Add-In manifest)
//_WebExtensionStoreReferenceVersion = "1.0.0.1" - matches version in manifest
//_WebExtensionStoreReferenceStore = path to manifest file
//_WebExtensionStoreReferenceStoreType = "FileSystem"
public static void AddWebExTaskpanesPart(WordprocessingDocument wordDoc, 
string _WebExtensionStoreReferenceId, string _WebExtensionStoreReferenceVersion, string _WebExtensionStoreReferenceStore, string _WebExtensionStoreReferenceStoreType)
{
    wordDoc.DeletePartsRecursivelyOfType<WebExTaskpanesPart>();
    wordDoc.DeletePartsRecursivelyOfType<WebExtensionPart>();
        
    WebExTaskpanesPart webExTaskpanesPart = wordDoc.AddWebExTaskpanesPart();
    WebExtensionPart webExtensionPart = webExTaskpanesPart.AddNewPart<WebExtensionPart>("rId1");
        
    We.WebExtension webExtension = new We.WebExtension() { Id = _WebExtensionStoreReferenceId };
    webExtension.AddNamespaceDeclaration("we", "http://schemas.microsoft.com/office/webextensions/webextension/2010/11");
        
    We.WebExtensionStoreReference webExtensionStoreReference = new We.WebExtensionStoreReference()
    {
        Id = _WebExtensionStoreReferenceId,
        Version = _WebExtensionStoreReferenceVersion,
        Store = _WebExtensionStoreReferenceStore,
        StoreType = _WebExtensionStoreReferenceStoreType
    };
        
    We.WebExtensionReferenceList webExtensionReferenceList = new We.WebExtensionReferenceList();
    We.WebExtensionPropertyBag webExtensionPropertyBag = new We.WebExtensionPropertyBag();
    We.WebExtensionProperty webExtensionProperty = new We.WebExtensionProperty() { Name = "Office.AutoShowTaskpaneWithDocument", Value = "true" };
    webExtensionPropertyBag.Append(webExtensionProperty);
        
    We.WebExtensionBindingList webExtensionBindingList = new We.WebExtensionBindingList();
        
    We.Snapshot snapshot = new We.Snapshot();
    snapshot.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
        
    webExtension.Append(webExtensionStoreReference);
    webExtension.Append(webExtensionReferenceList);
    webExtension.Append(webExtensionPropertyBag);
    webExtension.Append(webExtensionBindingList);
    webExtension.Append(snapshot);
        
    webExtensionPart.WebExtension = webExtension;
        
    //TaskPane
        
    Wetp.Taskpanes taskpanes = new Wetp.Taskpanes();
    taskpanes.AddNamespaceDeclaration("wetp", "http://schemas.microsoft.com/office/webextensions/taskpanes/2010/11");
        
    Wetp.WebExtensionTaskpane webExtensionTaskpane = new Wetp.WebExtensionTaskpane()
    {
        DockState = "left",
        Visibility = true,
        Width = 320D,
        Row = 0U,
        Locked = false
    };
        
    Wetp.WebExtensionPartReference webExtensionPartReference = new Wetp.WebExtensionPartReference() { Id = "rId1" };
    webExtensionPartReference.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
        
    webExtensionTaskpane.Append(webExtensionPartReference);
    taskpanes.Append(webExtensionTaskpane);
    webExTaskpanesPart.Taskpanes = taskpanes;
        
}

I set up a folder to serve up the referenced Add-In and it seems to work fine when I run it in my development environment. When I run the same code in my QA environment (different domain and certain settings of course), it seems to find the Add-In manifest because it brings up the TaskPane in Word, but it shows "We can't find the task pane to open. Contact the add-in developer for assistance." The Add-In itself seems to be working because when I add it to the Ribbon and click on the button, the Add-In comes up fine and even works with a Word doc.

I compared the two Word documents that were downloaded in dev and QA environments and except for the location of the Add-In manifest they are pretty much identical. I used Open XML SDK Productivity Tool for Microsoft Office to do the comparison (awesome tool by the way).

I don't have admin rights on the QA domain so can't run any debug tools there. Anyone have any ideas?

Rog O
  • 11
  • 1
  • 1
    Just to check the obvious thing: Doesn’t setting the StoreType to “FileSystem” mean that the actual addin has to be installed on a file system share accessible from the machine opening the addin, in this case in the QA environment, not your dev. Environment. If so, has the addin been copied there and does Word have the necessary access rights for that share? –  Nov 09 '20 at 21:58

1 Answers1

0

Did you also put the name "Office.AutoShowTaskpaneWithDocument" as the TaskPaneId in the Actions section in the manifest file?

<Action xsi:type="ShowTaskpane">
  <TaskpaneId>Office.AutoShowTaskpaneWithDocument</TaskpaneId>
  <SourceLocation resid="Contoso.Taskpane.Url" />
</Action>