4
如何获得使用Office.js(1.3)Word文档的作者或书名?有人能提供Office.js得到DocumentProperties的一个简单的例子?
我读documentProperties的文档,但我需要一个例子让语法正确。
帮助感谢!
如何获得使用Office.js(1.3)Word文档的作者或书名?有人能提供Office.js得到DocumentProperties的一个简单的例子?
我读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 + "'");
});
});
}
注意与Office.js API,则必须调用对象的方法load()
明确加载属性值,你就可以读取它。 (您可以找到有关在same article you linked to in your question的load()
方法的信息。)
也许这可以帮助有点https://github.com/OfficeDev/office-js-snippets/blob/master/samples/word/07-custom -Properties/GET-内置-properties.yaml – Slai