Get Layout's display name of a Google Presentation Slide via Google Apps Scripts

一个人想着一个人 提交于 2019-12-22 06:28:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!