Google sheet need to refresh after adding the AltTextTitle to image for apply changes

24 views
Skip to first unread message

Sajeeva Hasith

unread,
Dec 23, 2021, 6:08:48 AM12/23/21
to Google Apps Script Community

Google sheet, I want to add an image and add alter text title to the same image. But when I try to add alter text title, need to refresh the sheet to apply the changes.

Below is my current code:

  const sheet = SpreadsheetApp.getActiveSpreadsheet();

  const column = sheet.getActiveCell().getColumn();

  const row = sheet.getActiveCell().getRow();

  const inlineImage = sheet.insertImage(imageUrl, column, row);

  inlineImage.setAltTextTitle("some string value");

  SpreadsheetApp.flush();

Clark Lind

unread,
Dec 27, 2021, 11:04:19 AM12/27/21
to Google Apps Script Community
Try doing it all in the same call. This works for me, and the Alt text info is there when I look at the submenu:

  const inlineImage = sheet.insertImage(imageUrl, column, row)
    .setAltTextTitle("Some title")
    .setAltTextDescription("Some Description")
    .setHeight(200)
    .setWidth(150);


Capture.PNG

Full code for reference:
  const sheet = SpreadsheetApp.getActiveSpreadsheet();
  const column = sheet.getActiveCell().getColumn();
  const row = sheet.getActiveCell().getRow();
  const inlineImage = sheet.insertImage(imageUrl, column, row)
    .setAltTextTitle("Some title")
    .setAltTextDescription("Some Description")
    .setHeight(200)
    .setWidth(150);
 // inlineImage.setAltTextTitle("some string value");
  SpreadsheetApp.flush();
}

Reply all
Reply to author
Forward
0 new messages