【发布时间】:2017-06-27 19:06:09
【问题描述】:
我正在使用 Office JS API 开发 Word 插件。
目前我可以通过以下方式向 Word 文档添加自定义属性:
context.document.properties.load();
context.document.properties.customProperties.add("file-name-prop", "my file name");
如果我随后下载该文件,我可以在压缩 docx 内的“custom.xml”文件中看到该属性。
但我无法读取该属性。
我正在尝试这样做:
context.document.properties.load();
var filenameProp = context.document.properties.customProperties.getItemOrNullObject("file-name-prop");
if (filenameProp) {
// use filenameProp.value
} else {
// ignore, property not set
}
这样做时,我收到以下错误:
code : "PropertyNotLoaded"
message : "The property 'type' is not available. Before reading the property's value, call the load method on the containing object and call "context.sync()" on the associated request context."
name : "OfficeExtension.Error"
读回属性的正确方法是什么?
(我在用这个office js:appsforoffice.microsoft.com/lib/beta/hosted/office.js)
【问题讨论】:
标签: ms-office office365 office-js office-addins