Insert images from Google Drive into Google Slides using Apps Script

In this tutorial, I'll show you how easy it is to programmatically insert images from Google Drive into a Google Slides presentation using Apps Script.

In fact, this is so easy to do that the Apps Script code is just a few lines long!

Here is the code to get an image from Drive an insert it into a Google Slides presentation:

function insertImageFromDrive() {

  // Load the image from Google Drive
  var image = DriveApp.getFileById("<DRIVE_FILE_ID>");

  // Load the Google Slides presentation.
  var presentation = SlidesApp.openById("<SLIDES_ID>");

  // Insert the image into the first slide of your presentation.
  presentation.getSlides()[0].insertImage(image);
}

When you run the insertImageFromDrive() function, the image will be inserted into the first slide in your presentation.

Conclusion

In this tutorial, I showed you how easy it is to insert images from Google Drive into a Google Slides presentation using Apps Script.

Master Google Sheets Automation

Sign up to receive exclusive Automation tips and tutorials!
I'll send you actionable tips on automating tasks with Google Sheets and coding with Apps Script. You'll also be notified whenever new content is published.
PLUS: Get instant access to my Birthday Reminder Template! 🎂
By signing up you agree to the Privacy Policy & Terms.

Have feedback for me?

I'd appreciate any feedback you can give me regarding this post.

Was it useful? Are there any errors or was something confusing? Would you like me to write a post about a related topic? Any other feedback is also welcome. Thank you so much!