Reputation: 363
According to what I have learned while working with Office JS add-ins is that it is only possible to run JavaScript code only when some kind of action is initiated by the user manually on the Office client application (Word, Excel etc) such as by clicking on the button on the ribbon, or after loading the web page in the task pane.
I have a scenario where I need to run a background script as soon as the add-in is loaded in Office client app, and let it running until the client application has been closed, without having the user to interact with the add-in. I wanted to know if there is a way to make it work somehow, or any workarounds to achieve something similar? Thanks!
Upvotes: 0
Views: 859
Reputation: 9784
REVISED ANSWER: I'm afraid that there is no way to do that with Office Add-ins and office.js. There is no way to handle the sideloading event.
ORIGINAL ANSWER: Try putting your code inside the onReady() method or Office.initialize(). It will run immediately after Office initializes. For details, see Initializing your add-in and Loading the DOM and runtime environment.
Upvotes: 1