question

SylvainCornut-1899 avatar image
0 Votes"
SylvainCornut-1899 asked

Office Addin : I can’t call the function in the element <FunctionName> in the element <Action>

I'm currently working on a add-in for Word. In the manifest.xml, I have created a element that contains a element with a element of type button. I have an element of xsi: type = ExecuteFunction with a "testEventObject" function as a element. In the FunctionFile I call the commands.html page which contains script with the "testEventObject" method. I have placed an alert and a console.log in the function but when I click on the button, nothing happens. Thank you in advance for your help !


manifest.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

 <OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="TaskPaneApp">
    
   <Id>a963b4a9-15fa-4d1e-8bad-8c03c6027ad7</Id>
    
   <Version>1.0.0.0</Version>
    
   <ProviderName>Aproove</ProviderName>
    
   <DefaultLocale>en-US</DefaultLocale>
    
   <DisplayName DefaultValue="Aproove"/>
    
   <Description DefaultValue="Aproove description."/>
    
   <IconUrl DefaultValue="https://localhost:3000/assets/icon-32.png"/>
    
   <HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/icon-80.png"/>
    
   <SupportUrl DefaultValue="https://www.aproove.com/fr-fr/aproove-work-management-contact-us"/>
    
   <AppDomains>
     <AppDomain>https://www.aproove.com</AppDomain>
   </AppDomains>
    
   <Hosts>
     <Host Name="Document"/>
   </Hosts>
    
   <DefaultSettings>
     <SourceLocation DefaultValue="https://localhost:3000/taskpane.html"/>
   </DefaultSettings>
    
   <Permissions>ReadWriteDocument</Permissions>
   <VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
     <Hosts>
       <Host xsi:type="Document">
         <DesktopFormFactor>
    
           <GetStarted>
             <Title resid="GetStarted.Title"/>
             <Description resid="GetStarted.Description"/>
             <LearnMoreUrl resid="GetStarted.LearnMoreUrl"/>
           </GetStarted>
    
           <FunctionFile resid="Commands.Url"/>
    
           <ExtensionPoint xsi:type="PrimaryCommandSurface">
    
             <CustomTab id="Aproove.Tab">
    
               <Group id="Aproove.Tab1.Group1">
    
                 <Label resid="Aproove.Tab1.GroupLabel" />
    
                 <Icon>
                   <bt:Image size="16" resid="Icon.16x16" />
                   <bt:Image size="32" resid="Icon.32x32" />
                   <bt:Image size="80" resid="Icon.80x80" />
                 </Icon>
    
                 <Control xsi:type="Button" id="Aproove.TaskpaneButton">
    
                   <Label resid="Aproove.TaskpaneButton.Label" />
    
                   <Supertip>
    
                     <Title resid="Aproove.TaskpaneButton.Label" />
    
                     <Description resid="Aproove.TaskpaneButton.Tooltip" />
    
                   </Supertip>
    
                   <Icon>
                     <bt:Image size="16" resid="Icon.16x16" />
                     <bt:Image size="32" resid="Icon.32x32" />
                     <bt:Image size="80" resid="Icon.80x80" />
                   </Icon>
    
                   <Action xsi:type="ShowTaskpane">
    
                     <TaskpaneId>ButtonId1</TaskpaneId>
                    
                     <SourceLocation resid="Taskpane.Url" />
    
                   </Action>
                 </Control>
               </Group>
    
               <Group id="Aproove.Tab1.GroupSettings">
    
                 <Label resid="Aproove.Tab1.GroupLabelSettings" />
    
                 <Icon>
                   <bt:Image size="16" resid="Icon.16x16" />
                   <bt:Image size="32" resid="Icon.32x32" />
                   <bt:Image size="80" resid="Icon.80x80" />
                 </Icon>
    
                 <Control xsi:type="Button" id="Aproove.SettingsButton">
    
                   <Label resid="Aproove.SettingsButton.Label" />
    
                   <Supertip>
    
                     <Title resid="Aproove.SettingsButton.Label" />
    
                     <Description resid="Aproove.SettingsButton.Tooltip" />
    
                   </Supertip>
    
                   <Icon>
                     <bt:Image size="16" resid="Icon.16x16" />
                     <bt:Image size="32" resid="Icon.32x32" />
                     <bt:Image size="80" resid="Icon.80x80" />
                   </Icon>
                
                   <Action xsi:type="ExecuteFunction">
                     <FunctionName>testEventObject</FunctionName>
                   </Action>
                 </Control>
               </Group>
    
               <Label resid="Aproove.Tab.TabLabel" />
    
             </CustomTab>
    
           </ExtensionPoint>
         </DesktopFormFactor>
       </Host>
     </Hosts>
    
     <Resources>
    
       <bt:Images>
         <bt:Image id="Icon.16x16" DefaultValue="https://localhost:3000/assets/icon-16.png"/>
         <bt:Image id="Icon.32x32" DefaultValue="https://localhost:3000/assets/icon-32.png"/>
         <bt:Image id="Icon.80x80" DefaultValue="https://localhost:3000/assets/icon-80.png"/>
       </bt:Images>
    
       <bt:Urls>
         <bt:Url id="GetStarted.LearnMoreUrl" DefaultValue="https://go.microsoft.com/fwlink/?LinkId=276812"/>
         <bt:Url id="Commands.Url" DefaultValue="https://localhost:3000/commands.html"/>
         <bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/taskpane.html"/>
       </bt:Urls>
    
       <bt:ShortStrings>
         <bt:String id="GetStarted.Title" DefaultValue="Get started with your sample add-in!"/>
         <bt:String id="CommandsGroup.Label" DefaultValue="Commands Group"/>
         <bt:String id="TaskpaneButton.Label" DefaultValue="Show Taskpane"/>
    
         <bt:String id="Aproove.Tab.TabLabel" DefaultValue="Aproove"/>
         <bt:String id="Aproove.Tab1.GroupLabel" DefaultValue="Commands Group Aproove"/>
         <bt:String id="Aproove.TaskpaneButton.Label" DefaultValue="Show notes"/>
    
         <bt:String id="Aproove.Tab1.GroupLabelSettings" DefaultValue="User"/>
         <bt:String id="Aproove.SettingsButton.Label" DefaultValue="Settings"/>
       </bt:ShortStrings>
    
       <bt:LongStrings>
         <bt:String id="GetStarted.Description" DefaultValue="Your sample add-in loaded succesfully. Click here et click in the 'Show notes' button to view notes."/>
         <bt:String id="TaskpaneButton.Tooltip" DefaultValue="Click to Show a Taskpane"/>
         <bt:String id="Aproove.TaskpaneButton.Tooltip" DefaultValue="Click to Show a Taskpane"/>
    
         <bt:String id="Aproove.SettingsButton.Tooltip" DefaultValue="Click to show settings"/>
       </bt:LongStrings>
    
     </Resources>
   </VersionOverrides>
 </OfficeApp>

And the commands.html:

 <!DOCTYPE html>
 <html>
    
 <head>
     <meta charset="UTF-8" />
     <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    
     <!-- Office JavaScript API -->
     <script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js"></script>
    
     <script>
    
         Office.initialize = function () {
               
         }
         function testEventObject(event) {
              
             window.alert("hey");
             console.log("ici");
    
             event.completed();
         }
     </script>
 </head>
    
 <body>
      
 </body>
    
 </html>



office-addins-devoffice-js-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.

0 Answers