Ms office Word、body.getHtml()和body.getOoxml()方法的Office 2016 JavaScript API不起作用
尝试使用Office 2016 Word加载项获取Office 2016 Word文档正文时,java脚本API方法body.getHtml()和body.getOoxml()不起作用-; 它返回错误“调试信息:{“errorLocation”:“Body.getHtml”}” 参考文件-: 这是我的密码-:Ms office Word、body.getHtml()和body.getOoxml()方法的Office 2016 JavaScript API不起作用,ms-office,office-addins,office-js,javascript-api-for-office,Ms Office,Office Addins,Office Js,Javascript Api For Office,尝试使用Office 2016 Word加载项获取Office 2016 Word文档正文时,java脚本API方法body.getHtml()和body.getOoxml()不起作用-; 它返回错误“调试信息:{“errorLocation”:“Body.getHtml”}” 参考文件-: 这是我的密码-: Word.run(function (context) { // Create a proxy object for the document body.
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));
}
});
我是不是遗漏了什么
完整错误对象-:
{“name”:“OfficeExtension.Error”,“code”:“AccessDenied”,“message”:“AccessDenied”,“traceMessages”:[],“debugInfo”:{“errorLocation”:“Body.getHtml”},“stack”:“AccessDenied:AccessDenied\n at匿名函数()\n at yi()\n at st()\n at d()\n at c()”
错误代码5009->外接程序没有调用特定API的权限。
已尝试-:
还没有成功 您是使用Word中的API教程应用程序来尝试此示例,还是编写了自己的应用程序? 我刚刚在API教程应用程序(商店提供)中试用了这个示例,效果很好
// 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));
}
});
我正在尝试创建我自己的应用程序!!这是完整的错误对象:{“name”:“OfficeExtension.Error”,“code”:“AccessDenied”,“message”:“AccessDenied”,“traceMessages”:[],“debugInfo”:{“errorLocation”:“Body.getHtml”},“stack”:“AccessDenied:AccessDenied\n at匿名函数()\n at yi()\n at st()\n at st()\n at d()…在哪里可以找到您在回答中提到的示例应用程序?@PhilipRueker我正在尝试将段落或所有文档正文作为HTML内容,但文本即将中断。如何解决此问题并将所有内容作为HTML?我运行了此程序并得到了承诺:(它没有打印任何可能与word版本有关的内容。您当前的版本是什么?