如何使用Office.js(1.3)获取Word文档的作者或标题?
我阅读了有关documentProperties的文档,但需要一个示例来正确使用语法。
帮助赞赏!
以下代码片段获取文档的作者和标题,并将这些属性值写入控制台。
Word.run(function (context) {
var document = context.document;
document.properties.load("author, title");
return context.sync()
.then(function () {
console.log("The author of this document is " + document.properties.author + " and the title is '" + document.properties.title + "'");
});
});
Run Code Online (Sandbox Code Playgroud)
请注意,使用 Office.js API,您必须调用load()
对象上的方法以显式加载属性值,然后才能读取它。(您可以在问题中链接的同一篇文章load()
中找到有关该方法的信息。)
归档时间: |
|
查看次数: |
120 次 |
最近记录: |