2017-09-26 51 views

回答

1

下面的代码片段获取文档的作者,标题,写这些属性值到控制台。

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 questionload()方法的信息。)

相关问题