Created
June 14, 2017 07:35
-
-
Save JaKXz/1c8225d50bf0660205ff71a6cca3b929 to your computer and use it in GitHub Desktop.
Google Docs script to find the last active-ish row in a table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onOpen() { | |
// get the proparties we need to work with | |
var doc = DocumentApp.getActiveDocument(); | |
var body = doc.getBody(); | |
var tables = body.getTables(); | |
// find the last table [since there's more than one somehow] | |
var table = tables[tables.length - 1]; | |
var rows = table.getNumRows(); | |
// this will approach rows - 1 as more of the table is filled in. totally arbitrary right now. | |
// TODO: or, find a way to get the first empty row. | |
var lastRow = table.getRow(rows - rows/4); | |
// for some reason with newPosition, you have to trainwreck the call from DocumentApp otherwise the compiler complains | |
// *shrug* | |
var position = DocumentApp.getActiveDocument().newPosition(lastRow, body.getNumChildren()); | |
doc.setCursor(position); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment