I'm creating an Excel Add-in using Visual Studio, and I'd like to open the taskpane AND run some code from a button on the taskbar. In my manifest, I'm attempting to use
<Action xsi:type="ExecuteFunction">
<FunctionName>openAndRunStuff</FunctionName>
</Action>
and then in the js file:
function openAndRunStuff(event) {
var buttonId = event.source.id;
Office.addin.showAsTaskpane()
.then(function () {
});
event.completed();
The
When debugging, the line Office.addin.showAsTaskpane() runs, but doesn't open the taskpane. I read that's because I need a shared javascript runtime. To do that I need to put the following into the manifest:
<Runtimes>
<Runtime resid="ContosoAddin.Url" lifetime="long" />
</Runtimes>
as per https://docs.microsoft.com/en-us/office/dev/add-ins/reference/manifest/runtimes?view=office-js
This documentation says that <Runtimes> "Specifies the runtime of your add-in. Child of the <Host> element."
But when you click on the <Host> link in the doc, it takes you to <Host> which says it only allows the following children:
DesktopFormFactor Yes Defines the settings for the desktop form factor.
MobileFormFactor No Defines the settings for the mobile form factor. Note: This element is only supported in Outlook on iOS and Android.
AllFormFactors No Defines the settings for all form factors. Only used by custom functions in Excel.
The XML validator in my Visual Studio also does not like Runtimes being part of VersionOverrides / Hosts / Host, and therefore errors.
(Incidentally, my versionoverrides line in the xml file is:
<VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
But this URL doesn't appear to open in a browser)
SO - where should the <Runtimes> clause actually live please? (And should the docs be updated so the parent and child match)
Many thanks in advance!