2017-09-26 53 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()方法的信息。)

相關問題