1
votes

This is a question about a Google docs scripting document.

I would like to create a script that, when I run it, will transfer one row of data from a questionnaire (that I choose before running the script) to a completely new google docs word document.

Is this possible, and if so how would I do it?

1
This is not a programming question at all... please search for examples on this forum and elsewhere, you'll find a lot of scripts that do precisely what you are looking for. Come back after that if you meet specific programing issues. - Serge insas

1 Answers

0
votes

Shouldn't be too difficult - tricky bit comes with what you want to do with the data in the new doc. Example script to do this would be:

function sendToNewSheet() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var row = sheet.getActiveRange().getRowIndex();
  var range = sheet.getRange(row,1,1,sheet.getLastColumn()).getValues();
  var doc = DocumentApp.create(new Date().getTime());
  doc.appendParagraph(range.join());
  doc.saveAndClose();
}

function onOpen() {
  var subMenus = [{name:"Send to new sheet", functionName: "sendToNewSheet"}];
  SpreadsheetApp.getActiveSpreadsheet().addMenu("Help Desk Menu", subMenus);
}​

With that, you can select a cell in your spreadsheet and then use the menu to execute a function that will take the data in that cell's row, create a new document, and add the data into that document. If you wanted to name the document based on the data, you could do:

var doc = DocumentApp.create(range[0][1]);

Which would use the data in the second column. The document is created in your top level directory but you can move it after it's created into a specific folder you want.