gpt4 book ai didi

google-apps-script - 通过 Google Apps Scripts 获取 Google 演示幻灯片的布局显示名称

转载 作者:行者123 更新时间:2023-12-03 17:36:27 25 4
gpt4 key购买 nike

我正在尝试使用 Google Apps Scripts 创建的布局将新幻灯片附加到我的演示文稿中。

我开始了一个新的演示文稿,创建了两个新的布局,将它们命名为“BulletDescription”和“TextDescription”。
我可以获得演示文稿中可用的所有布局。但是,我找不到我按名称手动创建的布局。

function AddNewSlideToPresentation(LayoutType) //LayoutType = 'BulletDescription'
{
var presentation = SlidesApp.openById('PresentationID');
var layouts = presentation.getLayouts();
var selectedLayout;
for(var item in layouts)
{
Logger.log(layouts[item].getLayoutName());
if(layouts[item].getLayoutName() == LayoutType)
{
selectedLayout = layouts[item];
}
}

var newSlide = presentation.appendSlide(selectedLayout); // this returns an error
}

看来 .getLayoutName() 函数为我们提供了不同的名称,就像我在日志中找到的那样;
TITLE
SECTION_HEADER
TITLE_AND_BODY
MAIN_POINT
.
.
CUSTOM_1
CUSTOM_2

我相信 CUSTOM_1CUSTOM_2是我创造的。有没有办法通过 Google Apps 脚本获取布局的显示名称?

最佳答案

试试这个从 LayoutProperties 获取布局名称:

if (layouts[item].layoutProperties.displayName == LayoutType)
{
// found needed layout..
}

关于google-apps-script - 通过 Google Apps Scripts 获取 Google 演示幻灯片的布局显示名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47392442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com