1

Beim Versuch, Office 2016 Word-Dokumentkörper mit Office 2016 Word-Add-In, Java Script API-Methoden body.getHtml () und body.getOoxml() funktionieren nicht -; Es kehrt Fehler "Debug-Info: {" errorLocation ":" Body.getHtml "}"Office 2016 JavaScript API für Word, body.getHtml() und body.getOoxml() -Methoden funktionieren nicht

Referenzdokument -: http://dev.office.com/reference/add-ins/word/body

Hier ist mein Code-:

Word.run(function (context) { 

      // Create a proxy object for the document body. 
      var body = context.document.body; 

      // Queue a commmand to get the HTML contents of the body. 
      var bodyHTML = body.getHtml(); 

      // Synchronize the document state by executing the queued commands, 
      // and return a promise to indicate task completion. 
      return context.sync().then(function() { 
       $('#output').text("Body HTML contents: " + bodyHTML.value); 
      }); 
     }) 
     .catch(function (error) { 
      $('#output').text("Error: " + JSON.stringify(error)); 
      if (error instanceof OfficeExtension.Error) { 
       $('#output').text("Debug info: " + JSON.stringify(error.debugInfo)); 
      } 
     }); 

Am I etwas fehlt hier?

Abgeschlossen Fehler Object-: { "name": "OfficeExtension.Error", "Code": "AccessDenied", "message": "AccessDenied", "traceMessages" [] "debuginfo": { "errorLocation": "Body.getHtml"}, "stack": "AccessDenied: AccessDenied \ n bei anonymer Funktion (https://appsforoffice.microsoft.com/lib/1.1/hosted/word-win32-16.00.js:19:150094) \ n bei yi (https://appsforoffice.microsoft.com/lib/1.1/hosted/word-win32-16.00.js:19:163912) \ n bei st (https://appsforoffice.microsoft.com/lib/1.1/hosted/word-win32-16.00.js:19:163999) \ n bei d (https://appsforoffice.microsoft.com/lib/1.1/hosted/word-win32-16.00.js:19:163819) \ n bei c (https://appsforoffice.microsoft.com/lib/1.1/hosted/word-win32-16.00.js:19:162405) "}

Fehlercode 5009 -> Das Add-in keine Berechtigung die spezifische API aufrufen.

bereits versucht -: https://github.com/OfficeDev/office-js-snippet-explorer/issues/13 keinen Erfolg noch!

+0

Könnte mit der Version des Wortes verwandt sein. Was ist deine aktuelle Version? –

Antwort

0

Verwenden Sie die API-Lernprogramm-App in Word, um dieses Beispiel zu testen, oder haben Sie Ihre eigene App geschrieben? Ich habe gerade das Beispiel in der API Tutorial App (die im Store verfügbar ist) ausprobiert und es funktioniert gut.

// Run a batch operation against the Word object model. 
Word.run(function (context) { 

    // Create a proxy object for the document body. 
    var body = context.document.body; 

    // Queue a commmand to get the HTML contents of the body. 
    var bodyHTML = body.getHtml(); 

    // Synchronize the document state by executing the queued commands, 
    // and return a promise to indicate task completion. 
    return context.sync().then(function() { 
     console.log("Body HTML contents: " + bodyHTML.value); 
    }); 
}) 
.catch(function (error) { 
    console.log("Error: " + JSON.stringify(error)); 
    if (error instanceof OfficeExtension.Error) { 
     console.log("Debug info: " + JSON.stringify(error.debugInfo)); 
    } 
}); 
+0

Ich versuche meine eigene App zu erstellen !! – Kshitij

+0

Dies ist das vollständige Fehlerobjekt: ** {"name": "OfficeExtension.Error", "code": "AccessDenied", "Nachricht": "AccessDenied", "TraceMessages": [], "debugInfo": { "errorLocation": "Body.getHtml"}, "stack": "AccessDenied: AccessDenied \ n bei Anonymous-Funktion (https://appsforoffice.microsoft.com/lib/1.1/hosted/word-win32-16.00.js:19 : 150094) \ n bei yi (https://appsforoffice.microsoft.com/lib/1.1/hosted/word-win32-16.00.js:19:163912)\n at st (https://appsforoffice.microsoft.com) /lib/1.1/hosted/word-win32-16.00.js:19:163999)\n at d (https://appsforoffice.microsoft.com/lib/1.1/hosted/word-win32-16.00.js:19: 163819) .. ** – Kshitij

+0

wo ich diese Beispiel-App finden kann, die Sie in Ihrer Antwort erwähnt haben? – Kshitij

Verwandte Themen