Office Web App - Show task pane on load - ms-office

How do I show a custom taskpane automatically when the add-in loads (i.e. without having to click a command that is tied to that URL)?

Jan 2018 update:
Office has shipped a new feature which lets you configure your add-in to automatically open a task pane when the file loads if the add-in had been used there previously: https://learn.microsoft.com/en-us/office/dev/add-ins/design/automatically-open-a-task-pane-with-a-document.
Original Answer:
Commands cannot currently be used to launch a task pane when the document opens.
However, you can cause the task pane to open automatically if you remove all commands from the manifest entirely.

Related

Handle loading state of Excel AddIn or preload AddIn on insert

I'm developing an Excel AddIn and faced one issue.
1st issue: When user inserts the AddIn to the Excel (web) - user needs
to click any ribbon command to start loading plugin files.
2nd issue:
When plugin already inserted, the files are being downloaded.
However, if user click any command before files downloaded, nothing
happens.
I can disable all commands and enable them when source code downloaded. BUT this not works when user inserts AddIn for the first time. He MUST click any command to start downloading source code.
Question: is there any solution to force load Excel AddIn source on initial insertion?
P.S.
Startup behavior works only for the next opening of AddIn. If manifest has something similar - would be nice to know.
Env: Excel (on the web), OfficeJS API, Shared runtime, windows (if it's matter)
P.P.S. The problem - user clicks on enabled button to open taskpane, but nothing happens (the downloading just started).

Startup behavior doesn't work in Excel Desktop

I have an OfficeJS Excel Addin which is used in Online Excel and Desktop Excel. I use feature
Office.addin.setStartupBehavior(Office.StartupBehavior.load);
And it work fine for Online Excel: every time I start the excel - the plugin loads in background and ready to use.
However, in Excel Desktop it doesn't work. If I "alert" current behavior (after click on command to run the addin), it says "Load", but anyway it expects user interaction before to start loading the addin.
Any thoughts on this?
Prerequisites: SharedRuntime, Windows 10, Angular based addin
link to doc: https://learn.microsoft.com/en-us/office/dev/add-ins/develop/run-code-on-document-open
You can configure your Office Add-in to load and run code as soon as the document is opened. This is useful if you need to register event handlers, pre-load data for the task pane, synchronize UI, or perform other tasks before the add-in is visible. When your add-in is configured to load on document open, it will run immediately. The Office.initialize event handler will be called. Place your startup code in the Office.initialize or Office.onReady event handler. Read more about that in the Run code in your Office Add-in when the document opens article.

How to automatically show task pane for non-function add-in when opening worksheet?

How can we tell Excel (Web and Desktop) to load but not show an add-in automatically when a workbook is opened? We want code in the add-in to check the worksheet and, if our add-in has been used on it, open the add-in task pane automatically (though we'll give the user an opt-out of the behavior).
(The add-in is just a task pane, not custom functions.)
If you haven't already done that, I would recommed taking a look at the options for running code in your Office add-in when the document opens. From that page:
Configure your add-in to load when the document opens
The following code configures your add-in to load and start running when the document is opened.
Office.addin.setStartupBehavior(Office.StartupBehavior.load);
...
Place startup code in Office.initialize
When your add-in is configured to load on document open, it will run immediately. The Office.initialize event handler will be called. Place your startup code in the Office.initialize or Office.onReady event handler.

Close open Desktop Taskpane using office.js or Add-in manifest function

We have created add-in manifest xml file for our application and also embed office.js file.
We have use custom ribbon feature by assigning url to icon. When we click on icon, it open task pane on desktop. We want to open third party url in new window of browser using Add-in manifest and taskpane should be close.
We have gone through AppDomains and uses Office.addin.hide function. But both solutions are not working.
Please provide us solution if exist.
Office.js doesn't provide anything for opening a new tab in a web browser. Instead, you can display a popup message. In Excel, you can use the following code to hide the task pane:
Office.addin.hide();
For example:
function onCurrentQuarterDeactivated() {
Office.addin.hide();
}
See Show or hide an Office Add-in in a shared runtime for more information.
You may try to use UI less function, in UI less function, you could execute a javascript code to open a page in the default browser.
You could refer to this answer.
Open directly a web page from a button in Ribbon in a browser outside Excel?

Load an Office add-in or its add-in command by default

I take Excel for example. At the moment, every time when a user wants to use an add-in, they need to go to insert ==> add-ins and choose the add-in. Then either a take pane or content add-in appears. If the manifest xml of the add-in has add-in commands, users can launch the add-in via menu or ribbon.
If the user des-actives the task pane, closes and re-open Excel, they need to go to insert ==> add-ins again and so on... It is tedious.
Is it possible to set an add-in loaded by default (either by developers or users)? For example, each time the user opens Excel, they could see the item in the menu or ribbon (or even the task pane activated) to launch the add-in.
Unfortunately users have to always manually activate the add-in, either from a Ribbon command or from the Add-ins button. Only COM add-ins allow you to display a Task Pane when the Office application opens.
While the ribbon-button feature mentioned by SoftTimur and Eric is one solution to the problem, another potential solution (depending on your business model) may be to use a template:
You can create a .xlsx document and insert your add-in task pane manually, then share that document with others, who will automatically see the open task pane when they open that document. One strategy is to post this template document online and provide links to it elsewhere.

Resources