In order to protect the code (so people can't see it) I manage my Spreadsheet from a standalone script.
All functions work besides activating the sheet or cell (these functions work withing bound script, the calculations are correct, a cell gets activated).
I tried to activate the sheet from standalone script and then added it as a library and called from bound script of my file. None works.
I need to activate the sheet and the cell on spreadsheet opening.
Here's my code (bound to spreadsheet):
function onOpen() {
RandomNetwork.goToLastBlock()
}
Here's the code from a library (standalone script):
//goes to the last block on the sheet
function goToLastBlock() {
var file = SpreadsheetApp.openById("1kTOcxVv7RgIvp-BVvbZyBbeE92HiAKm8hbFURh19Enc")
var sheets = file.getSheets()
for (var i in sheets) {
var sheetID = sheets[i].getSheetId()
if (sheetID === 908402362) {
var lr = sheets[i].getLastRow()
var cell = sheets[i].getRange(lr, 1)
sheets[i].activate()
sheets[i].setCurrentCell(cell)
return
}
}
}
When I run it from the bound script it finds this spreadsheet and the sheet, calculates the last row correctly. But when I run from the script it doesn't do anything.
How can I activate the sheet and the cell from a standalone script? I'll appreciate any suggestions.
Logger.log(RandomNetwork.goToLastBlock)
– TheMaster