3

Is it possible to auto-open plugins that are in developer mode?

According to documentation

The pane that you designate to open automatically will only open if the add-in is already installed on the user's device. If the user does not have the add-in installed when they open a document, the autoopen feature will not work and the setting will be ignored. If you also require the add-in to be distributed with the document you need to set the visibility property to 1; this can only be done using OpenXML, an example is provided later in this article.

In particular, the file i'm attempting to auto-open is what based off office-generator with a single modification:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <we:webextension xmlns:we="http://schemas.microsoft.com/office/webextensions/webextension/2010/11" id="{acbc717b-5139-428a-9089-e9d6d7d8affc}">
  <we:reference id="acbc717b-5139-428a-9089-e9d6d7d8affc" version="1.0.0.0" store="developer" storeType="Registry"/>
  <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>

with the addition of <we:property name="Office.AutoShowTaskpaneWithDocument" value="true"/>

and by modifying manifest.xml as follows:

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

Problem:

It is expected that there would be one taskpane which would be opened automatically.

The task pane that was opened automatically has an error which states that we can't find the task pane to open. On the other hand, clicking on the ribbon allows the task pane to open as per normal, side by side with the broken auto-opened task pane as shown in the image below:

enter image description here

blackening
  • 903
  • 6
  • 14
  • Please use the Fiddler tool to compare HTTP Request/Response when the pane autoopens and when you press the button. – Rick Kirkham Jun 03 '19 at 01:50
  • @RickKirkham [Seems to be attempting to connect to office instead of localhost.](https://imgur.com/h2QsEtU). After the arrow is when i click the button to open the second taskpane. – blackening Jun 03 '19 at 05:25
  • @RickKirkham More specifically, it only attempts to connect to: `GET /ocs/docs/recent?rs=en-US&apps=Word&show=100 HTTP/1.1`, then `GET /ocs/locations/recent?rs=en-US&apps=Word&show=100 HTTP/1.1` and eventually `POST /rs/RoamingSoapService.svc HTTP/1.1`. It never attempts to hit localhost until i open the other taskpane. – blackening Jun 03 '19 at 05:32
  • @RickKirkham I have tried to implement Auto Open TaskPane feature with Office.context.document.settings.set("Office.AutoShowTaskpaneWithDocument", true) and saving this settings. but TaskPane is getting auto open for newly created documents only. For Older documents which are already present in a system(might be created maximum before a month), or them Task Pane is not getting auto open. – Sagar Mistry May 29 '23 at 13:44

1 Answers1

3

There's a hidden-state in Microsoft Word somewhere, that persists even after restarts. To reproduce the error you pretty much need a new computer.

Let me explain how i got it working after... 1 week.

First start with office-js generator.

yo office, for which i selected typescript.

enter image description here

Modify src/taskpane/taskpane.ts as follows:

export async function run() {
  return Word.run(async context => {
    /**
     * Insert your Word code here
     */

    // insert a paragraph at the end of the document.
    const paragraph = context.document.body.insertParagraph("Hello World", Word.InsertLocation.end);

    // change the paragraph color to blue.
    paragraph.font.color = "blue";

    // Add these two lines
    Office.context.document.settings.set("Office.AutoShowTaskpaneWithDocument", true);
    Office.context.document.settings.saveAsync();
    // Technically should wait, but doesn't matter.

    await context.sync();
  });

Modify manifest.xml as follows: Replace ButtonId1 with Office.AutoShowTaskpaneWithDocument

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

Launch the project as per normal. npm run start

Click the run button to trigger the creation of the auto-open file.

enter image description here

Save the file somewhere.

Re-open it to verify that it works. Funnily enough, it created an identical taskpanes when i clicked on the show taskpane button. This is a bug but works for me. It's for testing purposes after all.

enter image description here

To prove that the file's problem is indeed a hidden state: Clone the repo on a new computer, npm run start, copy the file over.

Run the file and you will get the same problem as i got in my original post.

blackening
  • 903
  • 6
  • 14