简体   繁体   中英

How to Change the Background Color of a Slide in Google Apps Script with Google Slides

I have been trying to figure out how to change the background color of a slide in Apps Script. I have tried setConcreteColor(DARK1, "#FF00FF"); , and the error code is ReferenceError: DARK1 is not defined . Can someone please help?

Recommended Solution:

You can use the setSolidFill() method. You may refer to this sample script below to change a slide page background color:

Script:

function myFunction() { 
  var hex_color = '#2a2a2a'; //The background color set in dark gray
  var selection = SlidesApp.getActivePresentation().getSelection();
  var currentPage = selection.getCurrentPage();
  var bg = currentPage.getBackground();
  bg.setSolidFill(hex_color);
}

Result:

From this:

在此处输入图像描述

To this:

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM