// Open a document by ID. var doc = DocumentApp.openById('DOCUMENT_ID_GOES_HERE'); // Open a document by URL. var doc = DocumentApp.openByUrl(url); // Get the document to which this script is bound. var doc = DocumentApp.getActiveDocument();