I am doing a script that extracts data from a google spreadsheet and generates google docs from that data. The script seems to work but five minutes is not enough to get through all my files, can anybody guide me in the right direction?
function createDocument() {
var sheetsURL="";
var title = Sheets.Spreadsheets.Values.get(sheetsURL, 'B1:B191');
var ksvalue = Sheets.Spreadsheets.Values.get(sheetsURL, 'A1:A191');
var q1 = Sheets.Spreadsheets.Values.get(sheetsURL, 'I1:I191');
var q2 = Sheets.Spreadsheets.Values.get(sheetsURL, 'J1:J191');
var q3 = Sheets.Spreadsheets.Values.get(sheetsURL, 'K1:K191');
var q4 = Sheets.Spreadsheets.Values.get(sheetsURL, 'L1:L191');
var templateId = '';
for(var i = 0; i < title.values.length; i++){
//declare vars to call later
var titles = title.values[i][0];
var ksv= ksvalue.values[i][0];
var q1s = q1.values[i][0];
var q2s = q2.values[i][0];
var q3s = q3.values[i][0];
var q4s = q4.values[i][0];
//Make a copy of the template file
var documentId = DriveApp.getFileById(templateId).makeCopy().getId();
//Rename the copied file
DriveApp.getFileById(documentId).setName('' + titles + ' '+ ksv +'');
//Get the document body as a variable
var body = DocumentApp.openById(documentId).getBody();
//replaces tags from the doc with the cells value
body.replaceText('##TITLE##', titles)
body.replaceText('##QUESTION1##', q1s)
body.replaceText('##QUESTION2##', q2s)
body.replaceText('##QUESTION3##', q3s)
body.replaceText('##QUESTION4##', q4s)
}
}