Google app 使用者介面的執行個體中的自訂選單。指令碼只能與
與目前開啟文件或表單的使用者介面互動,但前提是指令碼必須容器繫結。如要
請參閱選單指南。
// 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();
}
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2024-09-12 (世界標準時間)。"],[[["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."]]],[]]