スプレッドシートで使うGAS①
カスタムメニュー作成スプレッドシートを立ち上げた時のメニュー欄にオリジナルのプルダウンメニューが作成されるGASです。例3、4は入れ子になったサブメニューも作るタイプです。※対象のスプレッドシートに直接紐づいたGAS用です※トリガーの追加、承認手続きが必要です例1function onOpen() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const menuList = [];
menuList.push({ name: "処理1", functionName: "function1" });
menuList.push(null);
menuList.push({ name: "処理2", functionName: "function2" });
ss.addMenu("カスタムメニュー", menuList);
}例2function onOpen() {
const ui = SpreadsheetApp.getUi();
const menu = ui.createMenu('カスタムメニュー');
menu.addItem('処理1', 'function1');
menu.addToUi();
}例3 サブメニューのある例function onOpen() {
SpreadsheetApp.getUi()
.createMenu('カスタムメニュー')
.addItem('処理1', 'function1')
.addSeparato
0