Skip to content

Instantly share code, notes, and snippets.

@IranthaJ
Created January 18, 2016 17:57
Show Gist options
  • Select an option

  • Save IranthaJ/8d91ac4ed1280449c666 to your computer and use it in GitHub Desktop.

Select an option

Save IranthaJ/8d91ac4ed1280449c666 to your computer and use it in GitHub Desktop.
function onOpen(e) {
//method 1
SpreadsheetApp.getUi()
.createMenu('My Menu')
.addItem('My menu item', 'myFunction')
.addSeparator()
.addSubMenu(SpreadsheetApp.getUi().createMenu('My sub-menu')
.addItem('One sub-menu item', 'mySecondFunction')
.addItem('Another sub-menu item', 'myThirdFunction'))
.addToUi();
//method 2
var menuEntries = [
{ name : "Hello World", functionName : "myFunction" },
null,
{ name : "Second Function", functionName : "mySecondFunction" },
{ name : "Third Function", functionName : "myThirdFunction" }
];
SpreadsheetApp.getActiveSpreadsheet().addMenu( "My other Menu", menuEntries );
}
function myFunction() {
Browser.msgBox('Hello world!, this is cool');
}
function mySecondFunction()
{
Browser.msgBox('My second function');
}
function myThirdFunction()
{
Browser.msgBox('My third function');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment