user72840184
user72840184

Reputation: 43

Cannot insert image into Google Slides using app script

I am trying to insert an image into a Google Slide using an App script. I have:

  SlidesApp.getActivePresentation().insertImage('');

I get error insertPicture (Code:18)

Upvotes: 0

Views: 1303

Answers (1)

dxdc
dxdc

Reputation: 465

Review the Google documentation for inserting images.

First off, insertImage must be called on a specific slide, not a specific presentation. It needs to know where to put the image.

Secondly, the content of insertImage can't be empty like that. It needs to be a url, blob, etc.

For example, try some code like this:

var slide = SlidesApp.getActivePresentation().getSlides()[0];
slide.insertImage('https://upload.wikimedia.org/wikipedia/commons/5/56/Wiki_Eagle_Public_Domain.png');

Upvotes: 3

Related Questions