【问题标题】:How to Change the Background Color of a Slide in Google Apps Script with Google Slides如何使用 Google 幻灯片更改 Google Apps 脚本中幻灯片的背景颜色
【发布时间】:2021-07-21 21:14:28
【问题描述】:

我一直试图弄清楚如何在 Google Apps 脚本中更改幻灯片的背景颜色。

我试过setConcreteColor(DARK1, "#FF00FF");,它给了我错误代码:

ReferenceError: DARK1 is not defined.

有人可以帮忙吗?

(Apps 脚本文档: https://developers.google.com/apps-script/reference/slides/color-scheme)

【问题讨论】:

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


    【解决方案1】:

    推荐解决方案:

    您可以使用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);
    }
    

    结果:

    从这里:

    到这里:

    【讨论】:

      猜你喜欢
      • 2019-01-23
      • 1970-01-01
      • 1970-01-01
      • 2017-11-17
      • 1970-01-01
      • 1970-01-01
      • 2013-01-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多