exceloffice-jsoffice-addinsexcel-addinsexcel-web-addins

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.)


Solution

  • 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.