我正在尝试通过Google Apps脚本将新幻灯片添加到演示文稿中,并以创建的布局添加到演示文稿中。
我开始一个新的演示文稿,创建了两个新的布局,分别将其命名为“ 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
}
Run Code Online (Sandbox Code Playgroud)
似乎.getLayoutName()函数为我们提供的名称与我在日志中找到的名称不同;
TITLE
SECTION_HEADER
TITLE_AND_BODY
MAIN_POINT
.
.
CUSTOM_1
CUSTOM_2
Run Code Online (Sandbox Code Playgroud)
我相信,CUSTOM_1和CUSTOM_2是我创造的人。是否可以通过Google Apps脚本获取布局的显示名称?