Home > Enterprise >  Google Apps Script - Bookmark Elements of Table, Table Cell, Table Row in Google Docs
Google Apps Script - Bookmark Elements of Table, Table Cell, Table Row in Google Docs

Time:09-08

I want to achieve a bookmarking behavior like the example below using a custom script.

Selecting all table cells from the table:

enter image description here enter image description here

Select a table cell:

enter image description here enter image description here

Selecting table column from bottom to top: enter image description here enter image description here

CodePudding user response:

This is what worked for me:

function myFunction() {
  var doc = DocumentApp.getActiveDocument(); 
  var selection = doc.getSelection().getRangeElements();
  var pos = selection[0].getElement();
  doc.addBookmark(doc.newPosition(pos,0));
}

Screenshots:

Full table enter image description here

Column only enter image description here

Single table cell enter image description here

  • Related