google-apps-scriptbuttongoogle-drawings

Graphical buttons in my Google sheets don't keep their position


One of the annoying problems with Google sheet is the positioning the buttons. The buttons of the spreadsheet application may lose their original position ( due to user or unexpected behavior )

What to do ?


Solution

  • The best way to work around this problem is to programmatically reset the position of the buttons when the sheet is loaded.

    const drawings = sheet.getDrawings();
    const button = drawings.find(drawing => drawing.getOnAction() == "scriptName");
    button.setPosition(row, col, offset_X, offset_Y);