Reputation: 2485
Context
Currently I am developing an add-in for Word through the new Javascript API (office.js). The Javascript API offers developers the possibility to develop taskpanes, which is a column displayed next to a document. These taskpanes act as a browser and show a public or locally hosted webpage. Through the Javascript API these pages can interact with the document.
A single add-in can contain multiple taskpanes, that can be opened through so-called command add-ins. These command add-ins can be anything from buttons in the ribbon to an option in the right click menu. The specifications of these command add-ins and taskpanes are defined in a manifest. The word document reads this manifest and can therefore identify, what pages can be opened and how they should be displayed in Office.
The Goal
Ideally, I would like to create a number of documents that when opened by a user automatically open a certain taskpane from this add-in. Document A opens Taskpane A, Document B opens Taskpane B, so forth. However, for the sake of this question I would just like to focus on how to open a single taskpane from a manifest that contains multiple taskpanes. The documentation suggests that this is indeed possible as you can see here. The previously mentioned link, states that this can be achieved by following a number of steps.
(1) A webpage, with a reference to office.js is hosted.
(2) A manifest is created that contains a command add-ins and taskpanes. The taskpane that should be automatically opened has the id of 'Office.AutoShowTaskpaneWithDocument'.
<!--Example code, real manifest at the bottom of the question-->
<Action xsi:type="ShowTaskpane">
<TaskpaneId>Office.AutoShowTaskpaneWithDocument</TaskpaneId>
<SourceLocation resid="Contoso.Taskpane.Url" />
</Action>
(3) The Office Open XML of the document is adjusted, so that it contains a webextension. The webextension refers to the manifest and Office.AutoShowTaskpaneWithDocument id, so that it will open the right taskpane. This is done with adding the following webextension xml document (and rels document, not included here).
<we:webextension xmlns:we="http://schemas.microsoft.com/office/webextensions/webextension/2010/11" id="[ADD-IN ID PER MANIFEST]">
<we:reference id="[GUID or Office Store asset ID]" version="[your add-in version]" store="[Pointer to store or catalog]" storeType="[Store or catalog type]"/>
<we:alternateReferences/>
<we:properties>
<we:property name="Office.AutoShowTaskpaneWithDocument" value="true"/>
</we:properties>
<we:bindings/>
<we:snapshot xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"/>
</we:webextension>
The Problem
The document does open a taskpane, however it opens the url from the SourceLocation in the Taskpane Mode integration. The taskpane tagged with the Office.AutoShowTaskpaneId is completely ignored.
<!--Example code, real manifest at the bottom of the question-->
<!--Begin TaskPane Mode integration. This section is used if there are no VersionOverrides or if the Office client version does not support add-in commands. -->
<Hosts>
<Host Name="Document" />
</Hosts>
<DefaultSettings>
<SourceLocation DefaultValue="[baseurl]" />
</DefaultSettings>
<!-- End TaskPane Mode integration. -->
I assume that the VersionOverrides tag that contains all the information about the add-in is ignored. This would then result in the document opening the fallback from the DefaultSettings tag, therefore opening the wrong taskpane. Unfortunately I am completely lost on how I could resolve this issue. I have the newest version of Word and therefore the VersionOverrides tag should not be ignored.
Any help would be greatly appreciated!
EDIT I managed to solve it, but am unsure as what resulted in the solution. Rather than adjusting the OOXML that was generated by a local clientside add-in, I used the OOXML that was generated by the serverside add-in.
Although I am unsure as what the actual problem was. I presume that the Word cache at %LOCALAPPDATA%\Microsoft\Office\16.0\Wef\
played a role. The only changes I made were adjusting the OOXML with a server run add-in and cleaning the cache beforehand.
Appendix 1: Entire manifest, urls and names are changed.
<?xml version="1.0" encoding="UTF-8"?>
<!--Created:ce44715c-8c4e-446b-879c-ea9ebe0f09c8-->
<OfficeApp
xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides"
xsi:type="TaskPaneApp">
<!-- Begin Basic Settings: Add-in metadata, used for all versions of Office unless override provided. -->
<!-- IMPORTANT! Id must be unique for your add-in, if you reuse this manifest ensure that you change this id to a new GUID. -->
<Id>4a53b5db-f60a-4c32-82ee-2cf3f4954538</Id>
<!--Version. Updates from the store only get triggered if there is a version change. -->
<Version>1.0.0.1</Version>
<ProviderName>[Provider name]</ProviderName>
<DefaultLocale>nl-NL</DefaultLocale>
<!-- The display name of your add-in. Used on the store and various places of the Office UI such as the add-ins dialog. -->
<DisplayName DefaultValue="Add-in Name" />
<Description DefaultValue="Add-in Description"/>
<!-- Icon for your add-in. Used on installation screens and the add-ins dialog. -->
<IconUrl DefaultValue="[baseurl]/Images/Button32x32.png" />
<!--TODO: Nog toevoegen support pagina gegevens.-->
<SupportUrl DefaultValue="http://www.contoso.nl" />
<!-- Domains that will be allowed when navigating. For example, if you use ShowTaskpane and then have an href link, navigation will only be allowed if the domain is on this list. -->
<AppDomains>
<AppDomain>AppDomain1</AppDomain>
<AppDomain>AppDomain2</AppDomain>
<AppDomain>AppDomain3</AppDomain>
</AppDomains>
<!--End Basic Settings. -->
<!--Begin TaskPane Mode integration. This section is used if there are no VersionOverrides or if the Office client version does not support add-in commands. -->
<Hosts>
<Host Name="Document" />
</Hosts>
<DefaultSettings>
<SourceLocation DefaultValue="[baseurl]" />
</DefaultSettings>
<!-- End TaskPane Mode integration. -->
<Permissions>ReadWriteDocument</Permissions>
<!-- Begin Add-in Commands Mode integration. -->
<VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
<!-- The Hosts node is required. -->
<Hosts>
<!-- Each host can have a different set of commands. -->
<!-- Excel host is Workbook, Word host is Document, and PowerPoint host is Presentation. -->
<!-- Make sure the hosts you override match the hosts declared in the top section of the manifest. -->
<Host xsi:type="Document">
<!-- Form factor. Currently only DesktopFormFactor is supported. -->
<DesktopFormFactor>
<!--"This code enables a customizable message to be displayed when the add-in is loaded successfully upon individual install."-->
<GetStarted>
<!-- Title of the Getting Started callout. The resid attribute points to a ShortString resource -->
<Title resid="TextFrag.GetStarted.Title"/>
<!-- Description of the Getting Started callout. resid points to a LongString resource -->
<Description resid="TextFrag.GetStarted.Description"/>
<!-- Points to a URL resource which details how the add-in should be used. -->
<LearnMoreUrl resid="TextFrag.GetStarted.LearnMoreUrl"/>
</GetStarted>
<!-- Function file is a HTML page that includes the JavaScript where functions for ExecuteAction will be called.
Think of the FunctionFile as the code behind ExecuteFunction. -->
<FunctionFile resid="TextFrag.DesktopFunctionFile.Url" />
<!-- PrimaryCommandSurface is the main Office Ribbon. -->
<ExtensionPoint xsi:type="PrimaryCommandSurface">
<!-- Use OfficeTab to extend an existing Tab. Use CustomTab to create a new tab. -->
<CustomTab id="contoso.Tab1">
<!-- Ensure you provide a unique id for the group. Recommendation for any IDs is to namespace using your company name. -->
<Group id="contoso.Group1">
<!-- Label for your group. resid must point to a ShortString resource. -->
<Label resid="contoso.Group1Label" />
<!-- Icons. Required sizes 16,32,80, optional 20, 24, 40, 48, 64. Strongly recommended to provide all sizes for great UX. -->
<!-- Use PNG icons. All URLs on the resources section must use HTTPS. -->
<Icon>
<bt:Image size="16" resid="contoso.tpicon_16x16" />
<bt:Image size="32" resid="contoso.tpicon_32x32" />
<bt:Image size="80" resid="contoso.tpicon_80x80" />
</Icon>
<!-- Control. It can be of type "Button" or "Menu". -->
<Control xsi:type="Button" id="TextFrag.TaskpaneButton">
<Label resid="TextFrag.TaskpaneBtn.Label" />
<Supertip>
<!-- ToolTip title. resid must point to a ShortString resource. -->
<Title resid="TextFrag.TaskpaneBtn.Label" />
<!-- ToolTip description. resid must point to a LongString resource. -->
<Description resid="TextFrag.TaskpaneBtn.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="TextFrag.tpicon_16x16" />
<bt:Image size="32" resid="TextFrag.tpicon_32x32" />
<bt:Image size="80" resid="TextFrag.tpicon_80x80" />
</Icon>
<!-- This is what happens when the command is triggered (E.g. click on the Ribbon). Supported actions are ExecuteFunction or ShowTaskpane. -->
<Action xsi:type="ShowTaskpane">
<TaskpaneId>ButtonId1</TaskpaneId>
<!-- Provide a URL resource id for the location that will be displayed on the task pane. -->
<SourceLocation resid="TextFrag.Taskpane.Url" />
</Action>
</Control>
<!-- Control. It can be of type "Button" or "Menu". -->
<Control xsi:type="Button" id="Comm.TaskpaneButton2">
<Label resid="Comm.TaskpaneBtn.Label" />
<!--TODO: These do not seem to work, remove the reference to the Comm and make it generic.-->
<Supertip>
<!-- ToolTip title. resid must point to a ShortString resource. -->
<Title resid="Comm.TaskpaneBtn.Label" />
<!-- ToolTip description. resid must point to a LongString resource. -->
<Description resid="Comm.TaskpaneBtn.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Comm.tpicon_16x16" />
<bt:Image size="32" resid="Comm.tpicon_32x32" />
<bt:Image size="80" resid="Comm.tpicon_80x80" />
</Icon>
<!-- This is what happens when the command is triggered (E.g. click on the Ribbon). Supported actions are ExecuteFunction or ShowTaskpane. -->
<Action xsi:type="ShowTaskpane">
<TaskpaneId>ButtonId2</TaskpaneId>
<!-- Provide a URL resource id for the location that will be displayed on the task pane. -->
<SourceLocation resid="Comm.Taskpane.Url" />
</Action>
</Control>
</Group>
<Group id="contoso.Group2">
<Label resid="contoso.Group2Label" />
<Icon>
<bt:Image size="16" resid="contoso.tpicon_16x16" />
<bt:Image size="32" resid="contoso.tpicon_32x32" />
<bt:Image size="80" resid="contoso.tpicon_80x80" />
</Icon>
<Control xsi:type="Menu" id="Templates.Menu">
<Label resid="Templates.Dropdown.Label" />
<Supertip>
<Title resid="Templates.Dropdown.Label" />
<Description resid="Templates.Dropdown.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="contoso.tpicon_16x16" />
<bt:Image size="32" resid="contoso.tpicon_32x32" />
<bt:Image size="80" resid="contoso.tpicon_80x80" />
</Icon>
<Items>
<Item id="Templates.Menu.Item1">
<Label resid="Templates.Item1.Label"/>
<Supertip>
<Title resid="Templates.Item1.Label" />
<Description resid="Templates.Item1.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="contoso.tpicon_16x16" />
<bt:Image size="32" resid="contoso.tpicon_32x32" />
<bt:Image size="80" resid="contoso.tpicon_80x80" />
</Icon>
<Action xsi:type="ShowTaskpane">
<TaskpaneId>Office.AutoShowTaskpaneWithDocument</TaskpaneId>
<SourceLocation resid="Templates.Taskpane1.Url" />
</Action>
</Item>
<Item id="Templates.Menu.Item2">
<Label resid="Templates.Item2.Label"/>
<Supertip>
<Title resid="Templates.Item2.Label" />
<Description resid="Templates.Item2.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="contoso.tpicon_16x16" />
<bt:Image size="32" resid="contoso.tpicon_32x32" />
<bt:Image size="80" resid="contoso.tpicon_80x80" />
</Icon>
<Action xsi:type="ShowTaskpane">
<TaskpaneId>MyTaskPaneID2</TaskpaneId>
<SourceLocation resid="Templates.Taskpane2.Url" />
</Action>
</Item>
</Items>
</Control>
</Group>
<!-- Label of your tab -->
<!-- If validating with XSD it needs to be at the end, we might change this before release -->
<Label resid="contoso.Tab1.TabLabel" />
</CustomTab>
</ExtensionPoint>
</DesktopFormFactor>
</Host>
</Hosts>
<!-- You can use resources across hosts and form factors. -->
<Resources>
<bt:Images>
<bt:Image id="contoso.tpicon_16x16" DefaultValue="[baseurl]Images/IconTextFrag16x16.png" />
<bt:Image id="contoso.tpicon_32x32" DefaultValue="[baseurl]Images/IconTextFrag32x32.png" />
<bt:Image id="contoso.tpicon_80x80" DefaultValue="[baseurl]Images/IconTextFrag80x80.png" />
<!--Text fragment icons -->
<bt:Image id="TextFrag.tpicon_16x16" DefaultValue="[baseurl]Images/IconTextFrag16x16.png" />
<bt:Image id="TextFrag.tpicon_32x32" DefaultValue="[baseurl]Images/IconTextFrag32x32.png" />
<bt:Image id="TextFrag.tpicon_80x80" DefaultValue="[baseurl]Images/IconTextFrag80x80.png" />
<!--Committee text fragments -->
<bt:Image id="Comm.tpicon_16x16" DefaultValue="[baseurl]Images/IconCommittee16x16.png" />
<bt:Image id="Comm.tpicon_32x32" DefaultValue="[baseurl]Images/IconCommittee32x32.png" />
<bt:Image id="Comm.tpicon_80x80" DefaultValue="[baseurl]Images/IconCommittee80x80.png" />
</bt:Images>
<bt:Urls>
<!--General-->
<!--TODO: Solidify function file.-->
<!--TODO: Solidify GetStarted.LearnMoreUrl-->
<!--Text Fragments-->
<bt:Url id="TextFrag.DesktopFunctionFile.Url" DefaultValue="[baseurl]/Functions/FunctionFile.html" />
<bt:Url id="TextFrag.Taskpane.Url" DefaultValue="[baseurl]/Textfragments" />
<bt:Url id="TextFrag.GetStarted.LearnMoreUrl" DefaultValue="https://go.microsoft.com/fwlink/?LinkId=276812" />
<!--Committees-->
<bt:Url id="Comm.DesktopFunctionFile.Url" DefaultValue="[baseurl]/Functions/FunctionFile.html" />
<bt:Url id="Comm.Taskpane.Url" DefaultValue="[baseurl]/Communication" />
<bt:Url id="Comm.GetStarted.LearnMoreUrl" DefaultValue="https://go.microsoft.com/fwlink/?LinkId=276812" />
<!--Templates-->
<bt:Url id="Templates.Taskpane1.Url" DefaultValue="[baseurl]/Templates/Letter" />
<bt:Url id="Templates.Taskpane2.Url" DefaultValue="[baseurl]/InsertCommittee" />
</bt:Urls>
<!-- ShortStrings max characters==125. -->
<bt:ShortStrings>
<!--General-->
<bt:String id="contoso.Tab1.TabLabel" DefaultValue="Contoso" />
<bt:String id="contoso.Group1Label" DefaultValue="Group1" />
<bt:String id="contoso.Group2Label" DefaultValue="Group2" />
<!--Text Fragments-->
<bt:String id="TextFrag.TaskpaneBtn.Label" DefaultValue="Text fragments" />
<bt:String id="TextFrag.GetStarted.Title" DefaultValue="Description" />
<!--Committees-->
<bt:String id="Comm.TaskpaneBtn.Label" DefaultValue="Communication" />
<bt:String id="Comm.GetStarted.Title" DefaultValue="Description" />
<!--Templates-->
<bt:String id="Templates.Dropdown.Label" DefaultValue="Templates" />
<bt:String id="Templates.Item1.Label" DefaultValue="Letter" />
<bt:String id="Templates.Item2.Label" DefaultValue="Letter 2" />
</bt:ShortStrings>
<!-- LongStrings max characters==250. -->
<bt:LongStrings>
<!--General-->
<bt:String id="Comm.GetStarted.Description" DefaultValue="Description" />
<!--Text Fragments-->
<bt:String id="TextFrag.TaskpaneBtn.Tooltip" DefaultValue="Description" />
<bt:String id="TextFrag.GetStarted.Description" DefaultValue="Description" />
<!--Committees-->
<bt:String id="Comm.TaskpaneBtn.Tooltip" DefaultValue="Description" />
<!--Templates-->
<bt:String id="Templates.Dropdown.Tooltip" DefaultValue="Description" />
<bt:String id="Templates.Item1.Tooltip" DefaultValue="Description" />
<bt:String id="Templates.Item2.Tooltip" DefaultValue="Description" />
</bt:LongStrings>
</Resources>
</VersionOverrides>
<!-- End Add-in Commands Mode integration. -->
</OfficeApp>
Upvotes: 2
Views: 1696
Reputation: 9684
You can have only one TaskpaneId set to Office.AutoShowTaskpaneWithDocument. The URL assigned to the SourceLocation for that taskpane is hardcoded in the manifest. In your case it is [baseurl]/Templates/Letter
. So, every document on which you have enabled autoopen for this add-in should autoopen the Letter. There isn't going to be a way to install the very same add-in (hence, the very same manifest) on another document and have a different page autoopen.
Does add-in autoopen to [baseurl]/Templates/Letter
? If not, are you sure there is a file with that name and path? Is it an HTML file? What happens if you navigate a browser window to that URL when the add-in is running? Does the page load in the browser?
Upvotes: 2