0

I am trying to trigger a 3rd party Addin for Excel 365 online using a simple Typescript code written in the Scripts Automate window.

function main(workbook: ExcelScript.Workbook)
{
  // Your code here
  let element : HTMLElement = document.getElementsByClassName('button.root-415')[0] as HTMLElement;
  element.click();
}

But i am getting the following errors:

[4, 17] Cannot find name 'HTMLElement'.
[4, 31] Cannot find name 'document'. Do you need to change your target library? Try changing the `lib` compiler option to include 'dom'.
[4, 88] Cannot find name 'HTMLElement'.

Can someone help on how to trigger a click event on Excel Ribbon menu to Activate Addin menu and open its Task Pane?

4

2 回答 2

0

无论您尝试使用 Excel 插件脚本做什么,操作 DOM 元素都可能是错误的方法。

workbook您可以通过传递给您的函数的对象访问各种数据和main函数。工作簿界面在此处记录。

于 2021-11-29T10:15:39.740 回答
0

该错误表明您的项目的 .tsconfig 需要包含以下属性才能包含相关的 DOM 元素和函数类型:

{
  ...
  "lib": [..., "dom"]
}

编辑:您可能无法从 Excel 自动化面板访问 .tsconfig。请参阅我的其他答案。

于 2021-11-28T18:19:02.387 回答