google-apps-script - 谷歌应用程序脚本将自定义菜单功能添加到工作表

标签 google-apps-script

如何合并此代码,以便所有函数都列在同一标题(下拉列表)下?谢谢。

function onOpen ()
{ var sheet = SpreadsheetApp.getActiveSpreadsheet ();  

  var menu = [ {name: "extract e-mail",functionName: "GetAddresses"} ];  
  sheet.addMenu ("Extract E-mail", menu);    

  var menu = [ {name: "remove self",functionName: "readRows"} ];   
  sheet.addMenu ("AOA", menu); 

  var menu = [ {name: "remove duplicates",functionName: "removeDuplicates"} ];  
  sheet.addMenu ("Duplicates", menu); 

  var menu = [ {name: "send e-mail",functionName: "sendEmails"} ];  
  sheet.addMenu ("Mail Merge", menu); 

 }

最佳答案

您可以将菜单项作为对象数组传递。

function onOpen ()
{ 
  var sheet = SpreadsheetApp.getActiveSpreadsheet ();  
  var menu = [ 
    {name: "extract e-mail",functionName: "GetAddresses"},
    {name: "remove self",functionName: "readRows"},
    {name: "remove duplicates",functionName: "removeDuplicates"},
    {name: "send e-mail",functionName: "sendEmails"} 
  ];  
  sheet.addMenu ("Mail Merge", menu); 
 }

关于google-apps-script - 谷歌应用程序脚本将自定义菜单功能添加到工作表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45580138/

相关文章:

javascript - openById() 未打开电子表格

google-apps-script - 解压缩 Zip 然后使用 Google Apps 脚本解析 CSV 时遇到问题

google-apps-script - 如何从 Google 文档脚本授权和发布/更新 Trello 卡

javascript - Google Apps 脚本 - 检索用户名

google-apps-script - 接受来自用户的多个输入并添加到新行中的某些单元格

javascript - 用于匹配包含 URL 的字符串中的字母数字的正则表达式

javascript - Google Apps 脚本将日期插入 GSheets 但更改为未定义

javascript - 从 website/localhost 运行应用程序脚本功能

google-apps-script - 更改单元格值时触发 Google Sheet Script onChange

google-apps-script - 如何在配置设置中构建动态下拉菜单?