2

How do I consolidate this code so that all the functions are listed under the same heading (dropdown)? Thanks.

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); 

 }

1 Answer 1

2

You can pass the menu items in as an array of objects.

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); 
 }
Sign up to request clarification or add additional context in comments.

1 Comment

Excellent. Thanks. Thought it was simple ... I just kept getting syntax errors. Works now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.