我看过关于custom properties的MS Office js api 1.3文档。但是我无法通过office js从word设置中读取任何自定义属性项。
`Word.run(function (context) {
// Create a proxy object for the document.
var thisDocument = context.document;
var customProperties = thisDocument.properties.customProperties;
context.load(customProperties);
return context.sync().then(function () {
var getcount = customProperties.getCount();
console.log(customProperties.items);
return context.sync().then(function () {
console.log(getcount.value);
});
});
})`customProperties.items总是返回空数组。我在customProperties中也找不到set方法,我的自定义属性显示在这个(https://i.stack.imgur.com/AywDo.png)中。
MS Office js api是否还不支持访问word中的自定义属性?
发布于 2017-02-10 02:11:31
CallOfDuty:我认为发生的情况是你没有更新版本的办公客户端(你需要16/0.7766+)。我在最近的构建中运行了您的代码,我正在使用您的完全相同的代码获取自定义属性。所以请确保你正在进行一个新的更新,here are some instructions on how to do it。
顺便说一句,我刚刚得到了你的代码的一个简化版本。希望这能有所帮助!
function getProperties() {
Word.run(function (context) {
var customDocProps = context.document.properties.customProperties;
context.load(customDocProps);
return context.sync()
.then(function () {
console.log(customDocProps.items.length);
})
})
}
https://stackoverflow.com/questions/42106626
复制相似问题