How do I get the author or title of a Word document using Office.js (1.3)?
I read the documentation on documentProperties but I need an example to get the syntax right.
Help appreciated!
The following code snippet gets the author and title of the document and writes those property values to the console.
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 + "'");
});
});
Note that with the Office.js APIs, you must call the load()
method on an object to explicitly load the property value before you'll be able to read it. (You can find information about the load()
method in the same article you linked to in your question.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With