我不确定谷歌表脚本编辑器中的这个错误

时间:2017-03-05 13:03:57

标签: google-sheets

function onOpen() {
  var ui = SpreadsheetApp.getUi();
  // Or DocumentApp or FormApp.
  ui.createMenu('Useful Information')
      .addItem('How do I Book?', 'menuItem1')
      .addSeparator()
      .addItem('Where do I Screenshot?', 'menuItem2')
      .addSeperator()
      .addItem('How do I Book?', 'menuItem1')
      .addSeparator()
}

function menuItem1() {
  var app = UiApp.createApplication().setHeight('60').setWidth('150');
  app.setTitle("Here is a helpful link to the guide");
  var panel = app.createPopupPanel()
  var link = app.createAnchor('Click here! :D','http://prntscr.com/eg5x59');
  panel.add(link);
  app.add(panel);
  var doc = SpreadsheetApp.getActive();
  doc.show(app);
}

function menuItem2() {
  var app = UiApp.createApplication().setHeight('60').setWidth('150');
  app.setTitle("Here is a link to the radio");
  var panel = app.createPopupPanel()
  var link = app.createAnchor('Screenshot the red box using Lightshot','http://habboun.com/radio');
  panel.add(link);
  app.add(panel);
  var doc = SpreadsheetApp.getActive();
  doc.show(app);
}

function menuItem3() {
  var app = UiApp.createApplication().setHeight('80').setWidth('150');
  app.setTitle("Here is a link to the DOR page");
  var panel = app.createPopupPanel()
  var link = app.createAnchor('Post your Screenshot here on the most recent   Special Task. Format is dd/mm/yy - HH:MM-HH:MM', 'http://habboun.com/content/department-radio');
  panel.add(link);
  app.add(panel);
  var doc = SpreadsheetApp.getActive();
  doc.show(app);
}

所以我收到此错误http://prntscr.com/eg9ftl 我不知道如何解决它。请帮我。我查看了不同的论坛和所有内容,但我找不到解决方案,因为大多数解决方案都针对特定项目。

1 个答案:

答案 0 :(得分:0)

您显示的错误是

TypeError: Cannot find function addSeperator in object Menu.

“addSeperator”拼写错误。请从addSeperator更改为addSeparator。而onOpen()也需要“addToUi”。所以你的onOpen()脚本是

来自:

function onOpen() {
  var ui = SpreadsheetApp.getUi();
  // Or DocumentApp or FormApp.
  ui.createMenu('Useful Information')
      .addItem('How do I Book?', 'menuItem1')
      .addSeparator()
      .addItem('Where do I Screenshot?', 'menuItem2')
      .addSeperator()
      .addItem('How do I Book?', 'menuItem1')
      .addSeparator()
}

致:

function onOpen() {
  var ui = SpreadsheetApp.getUi();
  // Or DocumentApp or FormApp.
  ui.createMenu('Useful Information')
      .addItem('How do I Book?', 'menuItem1')
      .addSeparator()
      .addItem('Where do I Screenshot?', 'menuItem2')
      .addSeparator()
      .addItem('How do I Book?', 'menuItem1')
      .addSeparator()
      .addToUi();
}