0

I am attempting to build a user interface for a spreadsheet (whether through a menu add on or sidebar) that asks a user to select from a dynamic list of 'templates'. I want each item in the list of templates to run the below function with var templateName being the users selection in the list.

I have attempted a dynamic menu but this is not working for me

Google Apps Script: Dynamically creating spreadsheet menu items

Is this possible in apps script?

  function getTemplate(templateName){
  //Retrieves the template file and opens it to retrieve templates
  var getTemplateFile = DriveApp.getFilesByName('Evaluation Templates')
  while (getTemplateFile.hasNext())
  var openTemplates = getTemplateFile.next()
  var templateId = openTemplates.getId()
  var openSpreadsheet = SpreadsheetApp.openById(templateId)
  //Retrieves the template sheet tab by the name selected in the menu
  var getTemplateSheet = openSpreadsheet.getSheetByName(templateName)
  • Is what possible? And what's not working? – Cooper May 20 '20 at 17:05
  • Can you be more specific? Have you checked [Custom Menus in G Suite](https://developers.google.com/apps-script/guides/menus) – Kessy May 21 '20 at 09:53
  • I will try and be more specific: I want to create a list of the names of sheets in a spreadsheet. Set that list to a menu of some kind that allows a user to select one or the names. When the user selects a name, I want to use that selection in the "templateName" parameter in the last line of the above code. The other tricky part I am running into is allowing the list to be dynamic and change as I add more sheets. – Blade Rohloff May 22 '20 at 02:46
  • You could create a button on the sheet that gets the selected cell and its content. Once the user selects a cell and clicks the button the template name will be on the script. – Kessy May 27 '20 at 08:28

0 Answers0