question

KevinBrown-2736 avatar image
0 Votes"
KevinBrown-2736 asked KevinBrown-2736 answered

Office add-in runtimes in manifest

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!




office-addins-dev
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

KevinBrown-2736 avatar image
0 Votes"
KevinBrown-2736 answered

This error was caused by a bug (still open) in VS 2019.
See https://github.com/OfficeDev/office-js/issues/1756

The answer was to overwrite the local XSD (at: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Xml\Schemas\1033) with the latest XSD from here:

https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-owemxml/c6a06390-34b8-4b42-82eb-b28be12494a8

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.