Startup behavior doesn't work in Excel Desktop - excel

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.

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

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.

How do I use the setStartupBehavior API call?

I am trying to register event handlers when a document first opens up in Excel as it shows in the documentation. However, it tells me that I need to configure my code to include this: Office.addin.setStartupBehavior(Office.StartupBehavior.load); I'm not too sure where I am supposed to use this. I created my project using the yeoman generator for Office.
It depends on whether you want the users to decide whether the add-in runs when the file opens or whether you want to ensure that it does. If you want the user to decide, include this line of code in an event handler for a button or other UI. There's a sample add-in that does this at: Excel shared runtime scenarios.
If you want to ensure that the add-in runs whenever the file opens, then include the line of code in the Office.initialize method or Office.onReady method. The first time the file opens, the add-in will not run immediately and the user will have to manually invoke it. But, after that, the add-in will run whenever that file is opened.

Office Add-ins: Any way to have one always running?

I have an idea for an Office/PowerPoint Add-in. Most of the ones I've seen (and what is sampled in the documentation) are add-in actions that are triggered by a button click in the ribbon, or triggered by an action the sidebar. However, I need the Add-in to be running from the moment PowerPoint opens.
Is there a way to have a add-in that is running in the background? Listening for events? My idea involves catching when the slide changes - but I need this to happen when the PowerPoint is in Presenter view.
Is this currently possible?

Excel OLE - .NET COM AddIn behaves differently when Excel is embedded in an application

I have a .NET (C#) addin that uses a COM Shim dll to load itself into Excel. The addin works fine without any problem when Excel is run normally. The addin displays its own custom toolbar in Excel that is used to execute different commands.
When I embed Excel into another application (e.g. DSOFramer etc), the addin starts behaving strangely. It seems that if I disable a button on its toolbar then it does not get enabled again after setting the Visible property.
Also, I get a bunch of "Object reference not set" errors because the Application::Selection object is NULL which never happens when Excel is running normally. Sometimes I also get permission errors when Application::GetAddIns() method is called.
I am not sure what is happening here and I could not find an articles that explains the behavior of Excel COM Addins when Excel is embedded inside other application.
I have to admit I don't know much about dSOFramer, but I did run across the following items. I don't know if these help at all.
link text
link text
I contacted Microsoft Professional for this issue and found out that Microsoft now discourages embedding office applications. I was suggested to either stop embedding Excel into the application OR use only Excel 2007 that has a Ribbon UI. According to MS, the Ribbon UI does not have these issues.
The problem with the CommandBars is that the negotiation only happens during the OnConnection and no changes can be made afterwards.

Resources