Use column from GSpreadsheet for questions in GForm?
-
21-12-2019 - |
Question
I have a Google Spreadsheet that contains (among other things) one column with questions. Now I need to create a Google Form with N questions of type Text
for which the Question Title
is taken from my spreadsheet (where N is the number of rows in my spreadsheet; currently ~ 100).
Is there a straight-forward way of doing that?
Thank you for your time!
Solution
For your reference: https://developers.google.com/apps-script/reference/forms/
Create a app script in your spreadsheet like so:
function createForm(){
var form = FormApp.create('A New Form');
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Sheet1");
var rangeValues = sheet.getRange('A1:A20').getValues();
for (var x in rangeValues){
form.addTextItem().setTitle(rangeValues[x]);
}
Logger.log('Published URL: ' + form.getPublishedUrl());
Logger.log('Editor URL: ' + form.getEditUrl());
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow