"AccessDenied" WorksheetCollection.onActivated 事件 Excel 2019 桌面上的错误
"AccessDenied" error on WorksheetCollection.onActivated event on Excel 2019 Desktop
我的客户使用 "WorksheetCollection.onActivated" 事件在用户更改工作表时更新信息。他们发现在某些版本的 office 上尝试设置此事件时,加载项出现错误 "AccessDenied"。
async function registerOnActivateHandler() {
await Excel.run(async (context) => {
let sheets = context.workbook.worksheets;
sheets.onActivated.add(onActivate);
await context.sync();
console.log("A handler has been registered for the OnActivate event.");
});
}
代码在 Excel 在线和 Mac 上运行良好,我的客户确实在 Excel 2019 桌面版 16.0.10356.2006[=15= 上看到了 "Access Denied" 问题]
有趣的是:
onAdded/onDeactivated 事件在 Excel 2019 桌面
上正常运行
错误截图:
有没有人对这个问题有任何见解?
修复已推出。所以这个问题应该没有了。
============================================= =======================
这是一个已知问题,正在推出修复程序。
作为临时解决方案,请将以下代码添加到同一批 sheets.onActivated.add(onActivate)
中以解决问题。
// Call Write Operation APIs, bellow two line code equal to no-op.
let eventobj = sheets.onDeactivated.add(onDeactivate);
eventobj.remove();
例如,您的代码需要更新为
async function registerOnActivateHandler() {
await Excel.run(async (context) => {
let sheets = context.workbook.worksheets;
sheets.onActivated.add(onActivate);
// Call Write Operation APIs, bellow two line code equal to no-op.
let eventobj = sheets.onDeactivated.add(onDeactivate);
eventobj.remove();
await context.sync();
console.log("A handler has been registered for the OnActivate event.");
});
}
我的客户使用 "WorksheetCollection.onActivated" 事件在用户更改工作表时更新信息。他们发现在某些版本的 office 上尝试设置此事件时,加载项出现错误 "AccessDenied"。
async function registerOnActivateHandler() {
await Excel.run(async (context) => {
let sheets = context.workbook.worksheets;
sheets.onActivated.add(onActivate);
await context.sync();
console.log("A handler has been registered for the OnActivate event.");
});
}
代码在 Excel 在线和 Mac 上运行良好,我的客户确实在 Excel 2019 桌面版 16.0.10356.2006[=15= 上看到了 "Access Denied" 问题]
有趣的是: onAdded/onDeactivated 事件在 Excel 2019 桌面
上正常运行错误截图:
有没有人对这个问题有任何见解?
修复已推出。所以这个问题应该没有了。
============================================= =======================
这是一个已知问题,正在推出修复程序。
作为临时解决方案,请将以下代码添加到同一批 sheets.onActivated.add(onActivate)
中以解决问题。
// Call Write Operation APIs, bellow two line code equal to no-op.
let eventobj = sheets.onDeactivated.add(onDeactivate);
eventobj.remove();
例如,您的代码需要更新为
async function registerOnActivateHandler() {
await Excel.run(async (context) => {
let sheets = context.workbook.worksheets;
sheets.onActivated.add(onActivate);
// Call Write Operation APIs, bellow two line code equal to no-op.
let eventobj = sheets.onDeactivated.add(onDeactivate);
eventobj.remove();
await context.sync();
console.log("A handler has been registered for the OnActivate event.");
});
}