【问题标题】:How to pop alert message on google spreadsheet when "reopen" open the sheet?“重新打开”打开工作表时如何在谷歌电子表格上弹出警报消息?
【发布时间】:2021-11-22 02:29:28
【问题描述】:

我想在每次有人打开工作表时弹出警报消息。

function alertMessage() {

  SpreadsheetApp.getUi().alert("alert message");

}


function alertMessageYesNoCancelButton() {
  
  let a=3;

  var result = SpreadsheetApp.getUi().alert("Alert message", SpreadsheetApp.getUi().ButtonSet.YES_NO_CANCEL);

  while(a<5){
 
  SpreadsheetApp.getActive().toast(result);
  }

}

当我点击运行按钮并选择函数名来运行它时,警告信息只会显示一次。

当我重新打开工作表时,警报消息消失了。当我将链接发送给共享工作表的人时,他们也看不到警报消息。

【问题讨论】:

  • 请不要将图像用于代码和/或错误和输出,始终将其粘贴为文本并正确格式化。尝试用英语提供信息,你的错误(或警告,我什至不能说)是这里几乎没有人能理解的语言。当您无法阅读错误时,很难提供帮助:)

标签: google-apps-script google-sheets spreadsheet


【解决方案1】:

我发现我需要将我的函数名称更改为onOpen。每次有人打开电子表格时都会触发此功能。

function onOpen(e) {
  // Add a custom menu to the spreadsheet.
  SpreadsheetApp.getUi() // Or DocumentApp, SlidesApp, or FormApp.
      .createMenu('Custom Menu')
      .addItem('First item', 'menuItem1')
      .addToUi();
}

参考:

【讨论】:

    猜你喜欢
    • 2015-08-16
    • 1970-01-01
    • 1970-01-01
    • 2018-10-12
    • 2012-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多