1

In Google Slides it's possible to import slides deselecting "Keep original theme."

But this doesn't leave the imported slides with the desired layout from the current presentation's masters.

When attempting to re-apply the desired layout from the current presentation, this doesn't seem to have any effect on the imported slides. They seem to have kept some formatting.

So to fix that you have to manually select a slide, select its text elements/placeholders and choose "Clear formatting" from the Format menu.

That's a bit tiring and tedious. What I'd like to do is create a script that would cycle through the selected placeholders in the current slide and clear the formatting for each of them such that they (title, subtitle, body) adopt the style/layout of the relevant master from the current presentation.

Any suggestions?

Bonus points: cycle through selected slides and do the same.

function clearFormattingOfSlidesPlaceholders() {
  var selection = SlidesApp.getActivePresentation().getSelection();
  var type = selection.getSelectionType();
  switch (type) {
    case SlidesApp.SelectionType.PAGE:
      var pageRange = selection.getPageRange();
      if (pageRange) {
        var pages = pageRange.getPages();
        Logger.log('Clearing format for ' + pages.length + ' selected pages');
        for (var i = 0; i < pages.length; i++) {
          var page = pages[i];
          var slide = page.asSlide()
          // where to now?
        }
      } else {
        Logger.log('Clearing format for 0 selected pages');
      }
    default:
      break;
  }
}
ldeck
  • 227
  • 1
  • 10
  • If you've tried code, why haven't you included that code here, to benefit other askers and anyone attempting to help you? – tehhowch May 09 '18 at 12:57
  • @tehhowch I've been looking through the api docs and simply can't find the relevant function that would perform this if it exists. – ldeck May 09 '18 at 19:42
  • @tehhowch good suggestion nonetheless. I've added the code from where I got up to. – ldeck May 09 '18 at 19:49
  • Have you tried setting the layout and master of the selected slides based on that of the other slides? That's essentially what "clear formatting" means. You'll probably need to use the `Slides` REST API (available as an Advanced Service in Apps Script) to do this - looks like modifying the `masterObjectId` and `layoutObjectId` properties of the [`SlideProperties`](https://developers.google.com/slides/reference/rest/v1/presentations.pages#Page.SlideProperties) could be a place to start – tehhowch May 09 '18 at 21:09
  • https://stackoverflow.com/a/73646794/3525368 – vstepaniuk Sep 20 '22 at 12:31

0 Answers0