Create a RibbonCommands folder
Create a RibbonCommands.html file in this folder
Create a RibbonCommands.js file in this folder


This element specifies the file containing the javascript function that runs when a command that displays no UI, is pressed.
The javascript in the HTML file must call Office.initialize

Manifest File

<OfficeApp xsi:type="TaskPaneApp"> 
<VersionOverrides xmlns=" .../mailappversionoverrides/1.0
       xmlns: bt=".../officeappbasictypes/1.0
       xsi: type="VersionOverridesV1_0">
   <Host xsi:type = "MailHost">
         <FunctionFile resid="my-function-file-id"/>
      <bt:Url id="my-function-file-id"


This only needs to contain the javascript references

<script src="../hosted/office.js" type="text/javascript"></script> 
<script src="RibbonCommands.js" type="text/javascript"></script>


No initialisation code is required inside the Office.Initialize property.
However this property cannot be undefined so you need to include it with any empty body.
The method that will be called when the command executes needs a parameter passed into it.
In this snippet the method (or function) is called 'OnCommandButtonClick' and the parameter is given the name 'event'.
The very last time of this function needs to be 'event.completed()'.
This indicates to the host application that the function has finished and the UI can become responsive again.

Office.initialize = function() { 
function onCommandButtonClick(event) {
   event.completed(); //must be called

© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited TopPrevNext