首页 > 解决方案 > Office 插件 - context.runtime.load("enableEvents") 在 Window 中不起作用

问题描述

我正在尝试打开/关闭事件处理程序,context.runtime.load("enableEvents");但是在使用 Excel 2016 或更早版本的 Window 中的插件时遇到以下错误。

NotImplemented: This operation is not implemented.

我认为这个问题与 Internet Explorer 有关。在 Mac(任何 Excel 版本)或 Window(Excel 2019 或更高版本)中运行我的插件时,我没有这个问题。

重现:以下代码是此处找到的 Excel 插件的示例代码。只需添加该行context.runtime.load("enableEvents");,就会出现错误。

export async function run() {
  try {
    await Excel.run(async (context) => {
      /**
       * Insert your Excel code here
       */
      const range = context.workbook.getSelectedRange();

      // Read the range address
      range.load("address");

      // Update the fill color
      range.format.fill.color = "yellow";

      ///////// New code. Adding this line will cause error
      context.runtime.load("enableEvents");

      await context.sync();
      console.log(`The range address was ${range.address}.`);
    });
  } catch (error) {
    console.error(error);
  }
}

标签: office-jsoffice-addins

解决方案


推荐阅读