Skip to content

Instantly share code, notes, and snippets.

@wmakeev
Created August 5, 2014 17:16
Show Gist options
  • Select an option

  • Save wmakeev/7924d6c7f758c2d4af1c to your computer and use it in GitHub Desktop.

Select an option

Save wmakeev/7924d6c7f758c2d4af1c to your computer and use it in GitHub Desktop.
Create GoogleScript menu
function onOpen() {
var ui = SpreadsheetApp.getUi();
// Or DocumentApp or FormApp.
ui.createMenu('Custom Menu')
.addItem('First item', 'menuItem1')
.addSeparator()
.addSubMenu(ui.createMenu('Sub-menu')
.addItem('Second item', 'menuItem2'))
.addToUi();
}
function menuItem1() {
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.alert('You clicked the first menu item!');
}
function menuItem2() {
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.alert('You clicked the second menu item!');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment