This simple script will add a bookmark into your page and will insert a text into the document project.
The script needs to have the fix_cursor() add into the scripting area to avoid the crash cursor.
The fix_cursor() source code can be found on my previews tutorial.
Let’s see the script:
1 2 3 4 5 6 7 8 9 | function addBookmark() { var doc = DocumentApp.getActiveDocument(); var cursor = doc.getCursor(); fix_cursor() var element = cursor.getElement(); var bookmark = doc.addBookmark(cursor); var element = cursor.insertText('ಠ‿ಠ'); Logger.log(bookmark.getId()); } |