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

时间:2021-04-28 13:47:01

标签: google-apps-script google-apps google-slides

我一直在研究如何在 Apps Script 中更改幻灯片的背景颜色。我试过 setConcreteColor(DARK1, "#FF00FF");,错误代码是 ReferenceError: DARK1 is not defined。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

推荐的解决方案:

您可以使用 setSolidFill() 方法。您可以参考下面的示例脚本来更改幻灯片页面的背景颜色:

脚本:

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);
}

结果:

从这里:

enter image description here

为此:

enter image description here

相关问题