How can I move the cursor to the beginning of the document with Google Apps Script for Docs?
- 阅读更多 关于 How can I move the cursor to the beginning of the document with Google Apps Script for Docs?
问题 I am writing a script of Google Apps Script with my Google Document and wondering how to move the cursor to the very beginning of the document. What I was trying to do at the end is just replace the first line with some string. 回答1: This is very simple, you can use the setCursor() method documented here. Example code : function setCursorToStart() { var doc = DocumentApp.getActiveDocument(); var paragraph = doc.getBody().getChild(0); var position = doc.newPosition(paragraph.getChild(0), 0);