Reputation: 113
Am facing a problem in creating a menu in spreadsheet. where the same code works in another script. I dont know what am doing wrong. can someone please address it. It working when i run the function manually everytime.
function onOpen() {
var menu = [
{name: "Authorize", functionName: "authorize"},
{name: "Test", functionName: "testing"},
{name: "Notify", functionName: "notify"},
{name: "Clear", functionName: "clear"}
];
ss.addMenu("Testing ", menu);
}
where ss is declared outside.
Upvotes: 0
Views: 1283
Reputation: 713
I give an complete example about my code:
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Custom Menu')
.addItem('First', 'menu1')
.addToUi();
}
function menu1() {
SpreadsheetApp.getUi()
.alert('clicked');
}
function onOpen() {
var ss = SpreadsheetApp.getActive();
var items = [
{name: 'First', functionName: 'menu1'},
];
ss.addMenu('My Menu', items);
}
function menu1() {
Browser.msgBox('clicked');
}
Upvotes: 2
Reputation: 11278
Menu in spreadsheets may take a few seconds to appear. However if you do not see them, there's a possibility of some typo / bug in the code that is outside the onOpen() method.
Upvotes: 0