Skip to content

Instantly share code, notes, and snippets.

@user52839307
user52839307 / Add existing rows from a Google Sheets document as responses to a Google Form.js
Created March 12, 2024 18:38
To add existing rows from a Google Sheets document as responses to a Google Form, you'll need a workaround, as Google Forms doesn't natively support importing data directly into its response system. However, you can achieve this by using Google Apps Script to programmatically submit form responses. This process involves reading the rows from you…
// If your active sheet is not the same as the form respons sheet and does not have a Timestamp Column.
function submitFormResponses() {
var form = FormApp.openById('YOUR_FORM_ID'); // Replace with your Form ID
var spreadsheet = SpreadsheetApp.openById('YOUR_SPREADSHEET_ID'); // Replace with your Spreadsheet ID
var sheet = spreadsheet.getSheetByName('YOUR_SHEET_NAME'); // Replace with your Sheet name
// var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var data = sheet.getDataRange().getValues(); // Adjust this if your data starts from a different row/column
var items = form.getItems();
data.forEach(function(row, index) {
@user52839307
user52839307 / Google Form from a Google Sheets document.js
Last active March 12, 2024 15:31
Here's a basic example of how you could create a script to generate a Google Form from a Google Sheets document: 1. Open the Script Editor: In your Google Sheets, go to Extensions > Apps Script. 2. Replace the Code: Delete any code in the script editor and replace it with a custom script that reads the column headers from your sheet and creates …
function createFormFromSheet() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var range = sheet.getDataRange();
var values = range.getValues();
var headers = values[0]; // Assumes the first row contains headers
var form = FormApp.create('New Form from Sheet'); // Creates a new form
headers.forEach(function(header) {
form.addTextItem().setTitle(header);
});
@user52839307
user52839307 / slowtyping.applescript
Created April 17, 2023 03:30
This AppleScript emulates typing by outputting the contents of the clipboard with a delay between each keystroke.
(*
This AppleScript emulates typing by outputting the contents of the clipboard
with a delay between each keystroke, making it appear more like actual human typing.
The script retrieves the formatted clipboard contents as plain text and outputs each character
as a keystroke with a 0.1 second delay using the `keystroke` and `delay` commands in a `repeat` loop.
You can adjust the delay time to be shorter or longer by changing the value in the delay command.
*)