Created
January 18, 2016 17:57
-
-
Save IranthaJ/8d91ac4ed1280449c666 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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