我使用these steps创建了一个嵌入在SharePoint库中的Word加载项。 该加载项与使用add-ind内容类型创建的文档完美配合。 问题是当您将文档上载到文档库时,文档不会自动打开Word加载项。
我尝试了the guidance from the documentation,但它不起作用:
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>
github.com/OfficeDev/Office-OOXML-EmbedAddin上的示例,自动打开脚本实验室,使用GUID脚本实验室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;
}
答案 0 :(得分:0)
我认为胡安钉了它但是在这里添加了作为可见性的答案。您描述的方案是嵌入在文档中的加载项。
- 如果加载项使用命令(例如,在Word功能区上创建按钮),则按设计我们不会自动打开窗格。用户通过功能区上的按钮触发加载项,或者开发人员添加代码以自动打开加载项。关于如何使这项工作的article that you referenced has the instructions。但请注意,仅当您通过Centralized Deployment或Office Store分发加载项时才支持命令。它们使您的场景适用的关键是新文档需要已经使用触发窗格的相应OOXML标记进行标记;这是胡安提到的。