Google-sheets – Google Docs (or Sheets) API to scroll the view

google docsgoogle sheets

If I want to scroll to a particular paragraph in Google Docs, or a particular cell in Google spreadsheets, is there a way to do that via Google Apps Script?

Best Answer

For Google Doc Spreadsheet, you just need to set the active selection, the scroll is then done directly:

var file = SpreadsheetApp.getActiveSpreadsheet();
var sheet = file.getActiveSheet();
var row = LineToScrollTo;
file.setActiveCell(sheet.getRange(row,1));