Stay organized with collections Save and categorize content based on your preferences.
MenuA custom menu in an instance of the user interface for a Google App. A script can only interact with the UI for the current instance of an open document or form, and only if the script is container-bound to the document or form. For more information, see the guide to menus.
// Add a custom menu to the active spreadsheet, including a separator and a // sub-menu. function onOpen(e) { SpreadsheetApp.getUi() .createMenu('My Menu') .addItem('My Menu Item', 'myFunction') .addSeparator() .addSubMenu( SpreadsheetApp.getUi() .createMenu('My Submenu') .addItem('One Submenu Item', 'mySecondFunction') .addItem('Another Submenu Item', 'myThirdFunction'), ) .addToUi(); }Detailed documentation
addItem(caption, functionName)
Adds an item to the menu. The label for a menu item should be in sentence case (only the first word capitalized).
Parameters Name Type Descriptioncaption
String
The label for the menu item, with only the first word capitalized. functionName
String
The name of the function to invoke when the user selects the item. You can use functions from included libraries, such as Library.libFunction1
. Return
Menu
— This Menu
, for chaining.
addSeparator()
Adds a visual separator to the menu.
ReturnMenu
— This Menu
, for chaining.
addToUi()
Inserts the menu into the instance of the editor's user interface.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-02 UTC."],[[["The `Menu` class allows you to create custom menus in Google Apps Script, adding items, separators, and submenus."],["Menus can be used to provide users with easy access to script functionalities within the active document or form."],["Menu items are linked to specific functions within your script using the `addItem()` method."],["`addToUi()` inserts the created menu into the user interface of the current Google App instance."],["The provided code example demonstrates creating a basic custom menu with a submenu."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4