0
votes

I created a Word Add-in embedded in SharePoint library using these steps. The add-in works perfectly with documents created using the add-ind content type. The problem is the document doesn't automatically open the Word add-in when you upload documents to the Document Library.

I tried the guidance from the documentation, but it doesn't work:

 Office.context.document.settings.set("Office.AutoShowTaskpaneWithDocument", true);

Office.context.document.settings.saveAsync();
//code in the manifest file
<Action xsi:type="ShowTaskpane"> 
<TaskpaneId>Office.AutoShowTaskpaneWithDocument</TaskpaneId> 
<SourceLocation resid="Contoso.Taskpane.Url" /> 
</Action>

the sample on github.com/OfficeDev/Office-OOXML-EmbedAddin, automatically open script lab, does it reference the script lab using the GUID the script lab ID

     case "Word":

         using (var document = WordprocessingDocument.Open(memoryStream, true))
         {
         var webExTaskpanesPart = document.AddWebExTaskpanesPart();
         OOXMLHelper.CreateWebExTaskpanesPart(webExTaskpanesPart, snippetID);
         }
         break;
 // Adds child parts and generates content of the specified part.
        public static void CreateWebExTaskpanesPart(WebExTaskpanesPart part, string snippetID)
        {
            WebExtensionPart webExtensionPart1 = part.AddNewPart<WebExtensionPart>("rId1");
            GenerateWebExtensionPart1Content(webExtensionPart1, snippetID);

            GeneratePartContent(part);
        }

        // Generates content of webExtensionPart1.
        private static void GenerateWebExtensionPart1Content(WebExtensionPart webExtensionPart1, string snippetID)
        {
            We.WebExtension webExtension1 = new We.WebExtension() { Id = "{635BF0CD-42CC-4174-B8D2-6D375C9A759E}" };
            webExtension1.AddNamespaceDeclaration("we", "http://schemas.microsoft.com/office/webextensions/webextension/2010/11");
            We.WebExtensionStoreReference webExtensionStoreReference1 = new We.WebExtensionStoreReference() { Id = "wa104380862", Version = "1.1.0.0", Store = "en-US", StoreType = "OMEX" };
            We.WebExtensionReferenceList webExtensionReferenceList1 = new We.WebExtensionReferenceList();

            We.WebExtensionPropertyBag webExtensionPropertyBag1 = new We.WebExtensionPropertyBag();

            // Add the property that makes the taskpane visible.
            We.WebExtensionProperty webExtensionProperty1 = new We.WebExtensionProperty() { Name = "Office.AutoShowTaskpaneWithDocument", Value = "true" };
            webExtensionPropertyBag1.Append(webExtensionProperty1);

            // CUSTOM MODIFICATION BEGIN
            // Add the property that specifies the snippet to import.
            string snippetToImportValue = string.Format("{{\"type\":\"gist\",\"id\":\"{0}\"}}", snippetID);
            We.WebExtensionProperty webExtensionProperty2 = new We.WebExtensionProperty() { Name = "SnippetToImport", Value = snippetToImportValue };
            webExtensionPropertyBag1.Append(webExtensionProperty2);
            // CUSTOM MODIFICATION END

            We.WebExtensionBindingList webExtensionBindingList1 = new We.WebExtensionBindingList();

            We.Snapshot snapshot1 = new We.Snapshot();
            snapshot1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");

            webExtension1.Append(webExtensionStoreReference1);
            webExtension1.Append(webExtensionReferenceList1);
            webExtension1.Append(webExtensionPropertyBag1);
            webExtension1.Append(webExtensionBindingList1);
            webExtension1.Append(snapshot1);

            webExtensionPart1.WebExtension = webExtension1;
        }
1
Have you also updated your manifest as the article describes in Step 1: Specify the task pane to open? If you can update your post to include relevant parts of your manifest XML, perhaps someone will be able to repro your issue and provide helpful feedback. Also, I'd suggest that you compare what you're doing with the sample implementation to see what the differences may be.Kim Brandl
It only works for centralized deployment or store hosted addin. SharePoint catalog based addin don’t support auto open as far as I know.Sudhi Ramamurthy
Thanks for the info @SudhiRamamurthy. Can you please add this info as an "answer" below? (Others are more likely to benefit from this info in the future if it's added as an answer instead of just a comment.) Thanks!Kim Brandl
I'll double-check and add it as an answer shortly.Sudhi Ramamurthy
guys this has nothing to do with the type of catalog used. the problem here is that the uploaded documents do not have the "AutoShowTaskpane" setting on them. so they need to have a handler on document upload (on sharepoint) to inject the OOXML needed to do this. (via the XML sdk). in the referred article there is a sample OOXML that needs to be embedded.Juan Balmori

1 Answers

0
votes

I think Juan nailed it but adding here as answer for visibility. The scenario you describe is an add-in that is embedded on a document.

  • If the add-in doesn't use commands, by design, it remains visible if the user leaves the add-in pane open on a document. That is why you observe that documents created with the template auto-open the pane automatically. That is also why the pane doesn't automatically open when other documents just uploaded to the document library (because nobody used the add-in on them yet).

-If the add-in uses commands (e.g. creates button on Word the ribbon), by design, we do not automatically open a pane. Either users trigger the add-in via its button on the Ribbon or the developer adds code to automatically open the add-in. The article that you referenced has the instructions on how to make this work. Note however that commands are only supported if you distribute your add-in via Centralized Deployment or the Office Store. They key to make it work for your scenario is that new documents need to already be tagged with the appropriate OOXML markup that triggers the pane; this is what Juan alluded to.