I need at each open of the spreadsheets, to check for the available sheets in the spreadsheet and make a list add-on that Go to Specific sheet through click in the item list
The number of the sheets will be large and added dynamically through working
i'm blocking currently on making this "dummy" function take parameters so, when called it should open the sheet by its index
function onOpen() {
var monthPlanShortcuts = SpreadsheetApp.getUi().createMenu("Month Plan Shortcuts");
var gotoSheet = SpreadsheetApp.getUi().createMenu("Go to sheet");
// get properties to know who is the editor
var userProperties = PropertiesService.getUserProperties();
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
if (sheets.length > 1) {
for (var index = 0; index< sheets.length;index++)
{
var currentIndex = userProperties.setProperty("index",index);
gotoSheet.addItem(sheets[index].getName(),"dummy");
}
}
monthPlanShortcuts
.addItem('View Current Week Plan', 'gotoCurrentWeek')
.addItem('Go to Specific Week', 'gotoSpecificWeek')
.addSeparator()
.addSubMenu(gotoSheet)
.addToUi();
}
any suggestions??
.addItem('Title of Menu Item', 'function name')
to the function being called. So, there is no way to do what you want in one step from a menu. You would need to open a dialog box, or sidebar from the menu. Or open a sidebar automatically when the spreadsheet opens, and with HTML and JavaScript you can create something that will associate the sheet name with whatever code you want to run. – Alan Wells