'Open a task pane programmatically in OfficeJS

We can write action element in Menifest file to open a task pane:

<Action xsi:type="ShowTaskpane">
     <SourceLocation resid="readTaskPaneUrl" />
</Action>

We can easily display a dialog using this code:

Office.context.ui.displayDialogAsync(startAddress, options, callback);

I need to open a task pane programmaitaclly. Scenario is, using my add-in user can download a file and after download file will be opened in a new document programmaitaclly. I need to open a task pane on that newly opened document automatically.

How can I do this using OfficeJS API? Any suggestion or hints are welcome.

Update

Based on answer of @Rick Kirkham I have tried to open task pane programmaitaclly by following Automatically open a task pane with a document.

In my Menifest file:

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

In client side:

Word.run(function (context) {                
     var doc = context.application.createDocument(base64String);
     var _settings = doc.settings;
     _settings.add("Office.AutoShowTaskpaneWithDocument", true);


     return context.sync()
          .then(function () {
                 doc.open();
          }).catch(function (myError) {
                    //otherwise we handle the exception here!                        
     });

}).catch(errorHandler);

But still task pane is not opening automatically. Am I missing anything? Or should I try other way? Thanks in advance.

Note: I am using OfficeJS 1.4 beta version.



Solution 1:[1]

There is a way to automatically open a task pane when a document opens. See if this meets your needs: Automatically open a task pane with a document.

Edit: Regarding the updated question: Please save the doc, change it's extension from docx to zip, and open the zip file. Search the files in the zip package to see if the setting is actually there and set to true.

Also, I notice that you are using the Word Rich API version of document.settings.add(), where as the article uses the shared API version (and follows it with saveAsnyc(). I don't think that should matter, but as a trouble-shooting step, you might want to try the shared version of the API.

Also, does the button for opening the add-in at least appear in the doc, even if the task pane is not auto-opening?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1