Google Sheets – How to Create Multiple Menu Items

google sheetsgoogle-apps-script

I have two scripts I'm making:

  1. Shorten URLs within a Google Sheet
  2. Printing a single sheet and sending this as a PDF to a specified email

I have successfully created the first script and added it as a menu item in my Google Sheet, but notice that when I started working on the second script, the first menu item has disappeared!

Is there a way to have both scripts show as menu items please?

Best Answer

Rubén pointed out an example using getUi method, and here is a different one, using addMenu method. "Custom" is the menu name that will appear in the navigation bars, and the names in the list below will appear under it, and call the corresponding functions.

function onOpen() {
  SpreadsheetApp.getActiveSpreadsheet().addMenu("Custom", [
    {name: "Delete and Shift Up",       functionName: "deleteAndShiftUp"}, 
    {name: "Insert New Content Above",  functionName: "insertContentAbove"},
    {name: "Insert Blank Cells Above",  functionName: "insertAbove"},
  ]);
}