Skip to content

Instantly share code, notes, and snippets.

View phillypb's full-sized avatar

Phil Bainbridge phillypb

View GitHub Profile
function copyDoc_Paragraphs() {
// document ID of the file to be copied
var docId = 'insert your file ID';
// instruct DriveApp to get this document
var templateDoc = DriveApp.getFileById(docId);
// folder ID of where the copied file is to be saved
var folderId = 'insert your folder ID';
function splitUrlFile(Url) {
// remove this line when you incorporate into your script
var Url = 'https://drive.google.com/open?id=1ZvhkehvoL99EmmzUsy481givp31odMaO';
// split the Url via the equals sign to break into two
var split = Url.split('=');
// the file ID is the second part of the split (first part being zero)
var uploadID = split[1];
function onFormSubmit(e) {
// ******************************* get sheet data ******************************
var ss = SpreadsheetApp.getActiveSpreadsheet();
var formResponse = ss.getSheetByName('Form Responses 3');
var numCols = formResponse.getLastColumn();
var configArray = ss.getSheetByName('config').getDataRange().getValues();
Logger.log(configArray);
// *************************** end of get sheet data ***************************
function pushToArray() {
// create an empty array
var students = []
Logger.log('students array starts empty: ' + students);
// array with items to be pushed
var age = [7,8,9];
// loop through each item and push into empy array
function extractUrlID() {
// example Url
var Url = 'https://docs.google.com/file/d/0B-FYu_D7D7x4REdtRVEzVH0eU0/edit';
// use a regex to extract the ID
var expression = Url.match(/[-\w]{25,}/);
Logger.log(expression);
function createGroupSheets() {
// get relevant Sheets
var ss = SpreadsheetApp.getActiveSpreadsheet();
var studentSheet = ss.getSheetByName('Students');
var studentSheetName = studentSheet.getSheetName();
var studentSheetValues = studentSheet.getDataRange().getValues();
var studentLastRow = studentSheet.getLastRow();
function addPermissions() {
// get relevant Sheets
var ss = SpreadsheetApp.getActiveSpreadsheet();
var groupSheet = ss.getSheetByName('Groups');
var groupSheetName = groupSheet.getSheetName();
var groupSheetValues = groupSheet.getDataRange().getValues();
var groupLastRow = groupSheet.getLastRow();
function checkData(sheetName, sheet, lastRow, lastCol) {
Logger.log('Last Row is: ' + lastRow);
Logger.log('Last Column is: ' + lastCol);
var data = sheet.getRange(2, 1, lastRow, lastCol).getValues();
// loop through each Column ***********************************************
for (var i=0; i<lastCol; i++) {
function validationPopup(sheetName, column, j) {
var ui = SpreadsheetApp.getUi();
var result = ui.alert(
'Blank cell found in ' + sheetName + ' sheet',
'Please check cell: ' + column + (j+2),
ui.ButtonSet.OK);
}