Google Spreadsheet-无法加载自定义菜单,因为不会触发onOpen [英] Google Spreadsheet - Custom menu won't load because onOpen won't fire

查看:37
本文介绍了Google Spreadsheet-无法加载自定义菜单,因为不会触发onOpen的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在按照'定义电子表格菜单中的规定进行操作.教程.使用onOpen事件处理程序修改菜单.

I'm doing everything as prescribed in the 'Defining Spreadsheet Menus' tutorial. The menu is modified using the onOpen event handler.

我已经在脚本库"中公开提供了文本到列"脚本,但是我担心下载的用户可能会很困惑,因为它需要很长时间才能弹出自定义菜单.

I have made this 'Text to Columns' script available publicly in the 'Script Gallery' but I'm concerned that users who download may be confused when it takes a long time for the custom menu to pop up.

第一次下载脚本很痛苦.很多时候,完全错过了onOpen触发器.似乎触发器设置不正确,因为手动重置onOpen触发器会解决该问题.

Getting the script to load the first time is proving to be a pain. Much of the time the onOpen trigger is missed altogether. It appears that the trigger isn't being set correctly because manually resetting the onOpen trigger will fix it.

对于个人用途,我认为这是一个小麻烦,但是对于共享脚本,这会成为支持问题.

For personal use I'd consider this a minor annoyance but for a shared script it becomes a support issue.

注意:随后的每次加载始终需要大约7秒钟的时间才会出现,虽然可以,但还不理想.

以下是onOpen处理程序:

function onOpen() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var menuEntries = [];
  menuEntries.push({ name:"Text to columns", functionName:"textToColumns" });
  menuEntries.push({ name:"Text to columns (custom separator)", functionName:"textToColumnsCustom" });
  menuEntries.push(null);
  menuEntries.push({ name:"Columns to Text", functionName:"columnsToText" });
  menuEntries.push({ name:"Columns to Text (custom separator)", functionName:"columnsToTextCustom" });
  ss.addMenu("Advanced", menuEntries);
}

注意:这是在只有一个用户的新(即空)电子表格上进行的测试.

推荐答案

我不确定,但用户必须登录,我想是的,如果没有,我会遇到一次此问题,并通过拖曳或更多拖曳来解决触发它们都处于打开状态并且具有相同的功能,但是请尝试使Internet速度超过30KB/s,以确保问题出在代码上,而不是设备上

i'm not sure but the user have to log in i guess, if not, i've got this problem once and solved it with making tow or more triggers all of them are on open and the same function,however try to get internet speed more than 30KB/s to make sure that the problem is from the code , not from your devices

这篇关于Google Spreadsheet-无法加载自定义菜单,因为不会触发onOpen的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆