【发布时间】:2018-07-24 04:09:15
【问题描述】:
背景:
我正在 macOS 中开发一个插件,并且能够读取自定义文档属性:
return await this.api.run(async (context) => {
const properties = context.document.properties.customProperties;
properties.load('key,type,value');
await context.sync();
const roomID = properties.items.find(item => item.key === 'Webex_Teams_roomID');
return roomID ? roomID.value : null;
});
写一个:
return await this.api.run(async (context) => {
context.document.properties.customProperties.add('Webex_Teams_roomID', newRoomID);
await context.sync();
});
其中 this.api 只是 window.word 使用office JS API。我使用了 Microsoft 自己提供的以下 repo 的帮助,office-js-snippets。
问题:
我无法在 windows 的机器上运行我的代码。调试完代码后发现我的代码卡在了这个点:await context.sync();。
办公版本:
macOS 中的 Office 版本:16.14.1 (180613)。
Windows 中的 Office 版本:16.0.4639.1000 32-bit
更新:
经过一番挖掘,我发现我无法访问context.document.properties.customProperties.items。它将显示<permission denied> 错误。会是这样吗?
我将Permissions 设置为ReadWriteDocument:
<Permissions>ReadWriteDocument</Permissions>
没什么……
【问题讨论】:
标签: office-js office-addins excel-addins word-addins