Generate Google Slides from Google Sheets 😎

Do you spend a lot of time creating presentations at work? Perhaps you're a teacher who needs to create lesson plans or quizzes for your class? Or maybe you're a salesperson who creates presentations to pitch clients? Or just someone who (like me) creates lots of reports for all sorts of reasons!

Creating these presentations can take a lot of time and also it can become repetitive and boring. This is where some coding using Apps Script can be super useful. Using Google Slides, Google Sheets and Apps Script, you can automatically generate these presentations!!

In this tutorial, I will show you how to generate a Google Slides presentation using data from a Google Sheets spreadsheet.

4 steps to generate a Google Slides presentation template using data from a Google Sheets spreadsheet

Step 1 — Create a Google Slides presentation template

The first step is to create a Google Slides presentation to use as a template. I created a simple presentation for this tutorial that just has 2 slides: a title slide and a body slide.

Notice the curly braces around the words title, subtitle, slide1_title and slide1_body? The braces {{ }} tell us that the contents in between them are just placeholders and need to be substituted with the real content. These are called template variables.

In this tutorial, we'll be replacing these template variables with text using Apps Script.

Screenshot of a title slide in a Google Slides presentation template.Screenshot of a body slide in a Google Slides presentation template.

Step 2 — Create a Google Sheets spreadsheet and enter data corresponding to each template variable in the presentation

Open Google Sheets and enter the template variables in column A of a sheet called Data and enter the actual text you want inserted into the presentation in column B.

Screenshot of a Google Sheets spreadsheet.

Step 3 — Create an Apps Script to generate the presentation using the template and the data

First, open the Apps Script editor from Google Sheets by selecting Tools —> Script editor.

Then replace the code in the editor with the code below.

function fillTemplate() {

 // Id of the slides template
 // Remember to replace this with the Id of your presentation
 var PRESENTATION_ID = "<PRESENTATION_ID>";

 // Open the presentation
 var presentation = SlidesApp.openById(PRESENTATION_ID);

 // Read data from the spreadsheet
 var values = SpreadsheetApp.getActive().getDataRange().getValues();

 // Replace template variables in the presentation with values
 values.forEach(function(row) {
   var templateVariable = row[0]; // First column contains variable names
   var templateValue = row[1]; // Second column contains values
   presentation.replaceAllText(templateVariable, templateValue);
 });

}

Step 4 — Run your code to automatically replace the variables in the presentation with values coming from the spreadsheet

When you run the fillTemplate() function, the variables in your Google Slides template will be replaced with data coming from your Google Sheets spreadsheet. Isn't that awesome?

Conclusion

In just a few lines of code, we were able to read data from a Google Sheets spreadsheet and then populate these values in a Google Slides presentation template. Also, this code takes only a few seconds to run!

This is the power of automation and Google Apps Script makes it extremely easy to get started. I cannot think of any other programming language or platform where you can easily build such powerful applications in so few lines of code!

Now, imagine having to create dozens of presentations manually!! What if you could extend the code to create multiple presentations? I will show you how to do that in an upcoming tutorial. Stay tuned :).

Hope you found this tutorial helpful. Thanks for reading!

Stay up to date

Follow me via email to receive actionable tips and other exclusive content. I'll also send you notifications when I publish new content.
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!