简体   繁体   English

如何使用 Google 幻灯片更改 Google Apps 脚本中幻灯片的背景颜色

[英]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.我一直在试图弄清楚如何在 Apps Script 中更改幻灯片的背景颜色。 I have tried setConcreteColor(DARK1, "#FF00FF");我试过setConcreteColor(DARK1, "#FF00FF"); , and the error code is ReferenceError: DARK1 is not defined . ,错误代码为ReferenceError: DARK1 is not defined Can someone please help?有人可以帮忙吗?

Recommended Solution:推荐解决方案:

You can use the setSolidFill() method.您可以使用setSolidFill()方法。 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:对此:

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Google Apps 脚本或 API 判断 Google 幻灯片中的幻灯片是否“跳过”? - How to tell if a slide is "skipped" in Google Slides with Google Apps Script or API? Google 幻灯片:从 Apps 脚本中选择一张幻灯片 - Google Slides: Select a slide from Apps Script 使用 Google Apps 脚本更改 Google Doc 的背景颜色 - Change background color of Google Doc with Google Apps Script 有没有办法获取用户所在的当前幻灯片? Google 幻灯片和 Apps 脚本 - Is there a way to get the current slide the user is on? Google Slides, and Apps Script 如何使用 Google Apps Script 跳过 Google 幻灯片中的幻灯片? - How to skip slides in Google Slides with Google Apps Script? 使用应用程序脚本更改谷歌表格中周末日期列的背景颜色? - Change background color for columns with weekend dates in google sheets with apps script? 用于查找字符串并更改列背景颜色的 Google 应用程序脚本 - Google apps script to find a string and change the column background color 使用Apps脚本检测Google电子表格中的背景颜色变化 - Detect Background Color Change in Google Spreadsheet with Apps Script 谷歌应用脚本:谷歌幻灯片 - 使用“SlidesApp.create(”时是否可以拉入幻灯片文本或幻灯片编号? - Google apps script: Google Slides - Is it possible to pull in slide text or slide number when using "SlidesApp.create("? Google 应用程序脚本:Google 幻灯片 - 将选定的幻灯片导出到新的幻灯片演示文稿 - Google apps script: Google Slide - exporting selected slides to a new slide presentation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM