Inverting Selected Objects on Google Slides using Google Apps Script


This is a sample script for inverting the selected objects on Google Slides using Google Apps Script.

I have the case that I want to invert the selected objects on Google Slides. This sample script can be achieved this goal using Google Apps Script.

Sample script

Please copy and paste the following script to the script editor of Google Slides, and save the script. And, please select the objects on the Slide and run the function main(). By this, the selected objects are inverted.

function main() {
  const s = SlidesApp.getActivePresentation().getSelection();
  const selections = s.getPageElementRange();
  const obj = selections
    ? selections
        .reduce((o, e) => ((o[e.getObjectId()] = true), o), {})
    : {};
  const page = s.getCurrentPage();
  page.getPageElements().forEach((e) => {
    if (!obj[e.getObjectId()]);