Skip to content

Instantly share code, notes, and snippets.

@barrieroberts
barrieroberts / Docs-6
Last active November 13, 2024 05:12
Make Student Reports
//SCRIPT 1
function makeReports() {
//Get data
var ss = SpreadsheetApp.getActiveSpreadsheet(),
sheet = ss.getActiveSheet(),
data = sheet.getDataRange().getValues(),
company = data[0][0];
data.splice(0, 2);
//Get report template and report folder IDs
@barrieroberts
barrieroberts / Drive-1
Last active January 29, 2023 18:39
1-Creating files and folders in My Drive
//Create a text file
function example11() {
DriveApp.createFile("EXAMPLE 11 FILE", "This is a new file");
}
//Create a PDF
function example12() {
DriveApp.createFile("EXAMPLE 12 PDF FILE",
"This is a new PDF file", MimeType.PDF);
}
@barrieroberts
barrieroberts / Docs-5
Last active March 12, 2022 16:17
Create invoices2
//SCRIPT 1
function makeInvoice() {
//Get invoice data
const ss = SpreadsheetApp.getActiveSpreadsheet(),
sh = ss.getSheetByName('INVOICES'),
fInvoices = DriveApp.getFolderById('FOLDER ID'),
timeZone = Session.getScriptTimeZone(),
data = sh.getDataRange().getValues();
var invoiceNumb = data[0][6];
//Make reports in Google Docs from data in a Google Sheet, then email them as PDFs
function makeSendReports() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sh = ss.getActiveSheet();
const [header, ...data] = sh.getDataRange().getDisplayValues();
const group = header[0].split(" - ")[0];
const teacher = header[0].split(" - ")[1];
const docMaster = DriveApp.getFileById('12MEOOsfFrxsQzBXqDe0gOTacncpaDoykTuWgoT5rzqI');
const placeholders = ['#NAME#', '#GROUP#', '#TEACHER#', '#READING#', '#WRITING#', '#SPEAKING#', '#LISTENING#', '#OVERALL#'];
@barrieroberts
barrieroberts / Adding different types of questions to a Google Form
Last active December 30, 2021 12:50
13-Adding different types of questions to a Google Form
//Create new form - Global variable so it can be seen by all functions
const FORM = FormApp.create("Questionnaire");
function makeQuestionnaire() {
//Get data and last row from spreadsheet
const sh = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1");
const data = sh.getDataRange().getValues();
//Loop through each question and check what question type it is
data.forEach(checkQuestionType)
function onOpen() {
const ui = SpreadsheetApp.getUi();
ui.createMenu('Reports')
.addItem('Make pdfs', 'createReports')
.addItem('Email reports', 'sendEmails')
.addToUi();
}
function createReports() {
//Get data from sheet and remove header
const ss = SpreadsheetApp.getActiveSpreadsheet();
@barrieroberts
barrieroberts / Parents Evening Appointment System
Last active December 28, 2021 20:22
Parents Evening Appointment System
//PART 2
function onOpen() {
const ui = SpreadsheetApp.getUi();
ui.createMenu('Admin')
.addItem('Set up forms & sheets', 'setUpForms')
.addToUi();
}
function setUpForms() {
//Folder to store forms in - Add your own folder ID here
@barrieroberts
barrieroberts / Docs-10
Last active April 5, 2021 23:12
Conference talk information-webapp form
//Stand alone script file
//SCRIPT 1
function doGet() {
//Get talks
var ssConf = SpreadsheetApp.openById('SPREADSHEET ID');
var shTalkInfo = ssConf.getSheetByName('TALKINFO');
var allTalkInfo = shTalkInfo.getDataRange().getValues();
allTalkInfo.shift();
//Build form
@barrieroberts
barrieroberts / Docs-9
Last active April 5, 2021 23:09
Conference talk information
//Bound to a Google Form
//SCRIPT 1
//Get talks from form submission
function getFormSubmission(e) {
const form = FormApp.getActiveForm();
//Get list of talks selected
const lastRespNo = form.getResponses().length - 1;
const latestResp = form.getResponses()[lastRespNo];
const listOfTalks = latestResp.getItemResponses()[0]
@barrieroberts
barrieroberts / Docs-8
Last active April 5, 2021 23:06
Multiple-page certificates
//Bound to a spreadsheet
//SCRIPT 1
function makeCerts() {
const ss = SpreadsheetApp.getActiveSpreadsheet(),
shCerts = ss.getSheetByName('CERTIFICATES'),
data = shCerts.getDataRange().getValues();
//Column array references and row numbers
const startRowNum = data[0][4], endRowNum = data[0][6];