Skip to content

Instantly share code, notes, and snippets.

@cristianca
Created August 27, 2014 09:46
Show Gist options
  • Save cristianca/716dd73028b6abfd9b9d to your computer and use it in GitHub Desktop.
Save cristianca/716dd73028b6abfd9b9d to your computer and use it in GitHub Desktop.
// insert text at cursor position in a Google Docs using apps script.
function insertTextAtCursorPosition(text) {
var doc = DocumentApp.getActiveDocument();
var cursor = doc.getCursor();
if (cursor) {
text = cursor.insertText(text);
position = doc.newPosition(text, text.getText().length);
doc.setCursor(position);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment