Search code examples
javascriptexceloffice-jsoffice-addinsexcel-addins

Automatically load and start runtime of Office-js add-ins for all documents


I'm developing an office-js add-in that needs to run automatically (without user interaction) every time any Excel document starts. I have configured it to use a shared runtime. This capability exists for VSTO add-in which load when Excel starts but seems to be missing for Office-js addins.

I only found two possible solutions, but they don't work that well:

  1. When the add-in runs for the first time in a document, set Office.addin.setStartupBehavior(Office.StartupBehavior.load) so that the add-in loads automatically for the document.

Issue: the add-in needs to be manually inserted once (the user needs to click on the add-in ribbon once per document). This setting only applies to the current document. Not practical since users first need to interact with the add-in for every new document.

  1. As Excel opens a new document, use a VSTO add-in to insert the add-in by editing the document using OpenXML following this article https://learn.microsoft.com/en-us/office/dev/add-ins/develop/run-code-on-document-open.

Issue: Excel blocks I/O for documents as they are opened. For local documents, I found a way to write onto them as Excel writes on them, but when the documents are saved on OneDrive, any stream with ReadWrite attributes can't get access. So this solution is not working very well.

Is there a workaround possible?


Solution

  • No, there is no other way to get Excel web add-ins loaded automatically.