问题
I am trying to append a new slide to my presentation with a created layout via Google Apps Scripts.
I started a new presentation, created two new layouts, named them as 'BulletDescription' and 'TextDescription'. I can get all the layouts available in the presentation. However, I can't find the layouts which I manually created by their names.
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
}
It seems that .getLayoutName() function gives us different name as I found on my log;
TITLE
SECTION_HEADER
TITLE_AND_BODY
MAIN_POINT
.
.
CUSTOM_1
CUSTOM_2
I believe CUSTOM_1
and CUSTOM_2
are the ones I created. Is there a way to get display name of the layout via Google Apps Script?
来源:https://stackoverflow.com/questions/47392442/get-layouts-display-name-of-a-google-presentation-slide-via-google-apps-scripts