2
votes

I'm trying to select a newly created slide with the API call selectAsCurrentPage() (using Google Apps Script):

var slide = SlidesApp.getActivePresentation().appendSlide(SlidesApp.PredefinedLayout.TITLE_AND_BODY);
slide.selectAsCurrentPage();

But it seems, that the selectAsCurrentPage() doesn't work as I expected - it loads that slide into the main edit area, but the slide is not selected in the left timeline panel (it's not decorated with a grey rectangle as if I select the slide manually, instead there is a black line on top of the timeline):

Current behaviour Current behaviour

Expected behaviour Expected behaviour

So, how it is possible to select that slide also in the left timeline?

1

1 Answers

2
votes

Unfortunately, in the current stage, there are no method for directly achieving the situation yet. So how about this workaround? The flow of this workaround is as follows. I think that there might be several workarounds. So please think of this as just one of them.

  1. Append a slide using appendSlide().
    • This is from your script.
  2. Insert a text box as a dummy object.
    • I think that anything objects can be used for this situation.
  3. Select the dummy object.
  4. Remove the dummy object.

By this flow, the appended slide is selected. The sample script is as follows.

Sample script:

var slide = SlidesApp.getActivePresentation().appendSlide(SlidesApp.PredefinedLayout.TITLE_AND_BODY);
var obj = slide.insertTextBox(""); // Added
obj.select(); // Added
obj.remove(); // Added

References:

If this was not the result you want, I apologize.