Generate Google Slides from Google Sheets
Do you spend hours creating presentations for work, classes, or client pitches? What if you could automate this process and save valuable time? In this tutorial, you'll learn how to use Google Apps Script to automatically generate Google Slides presentations using data from Google Sheets.
What is Google Apps Script?
Google Apps Script is a powerful scripting platform that integrates with Google Workspace applications. It allows you to automate tasks, create custom functions, and build applications that work seamlessly with Google products like Sheets, Docs, and Slides.
What You'll Learn
In this tutorial, you'll discover how to:
Create a Google Slides presentation template
Prepare data in Google Sheets
Write a simple Apps Script to populate your presentation
Run the script to generate your slides automatically
Let's dive in and automate your presentation creation process!
PrerequisitesBasic Google Sheets usage: You should know how to create spreadsheets, enter data, and navigate the Google Sheets interface. If you need a refresher, check out Google's Sheets tutorial.
How to create and run simple Apps Script scripts using the script editor in Google Sheets If you need a refresher, check out this guide on creating your first Apps Script.
What arrays are and how to use them in Apps Script For a review of arrays in Apps Script, see this article on arrays in Apps Script.
forEach loop in Apps Script If you need to brush up on the forEach loop, refer to this guide on forEach loop in Apps Script.
Reading from and writing to a range in Google Sheets using Apps Script For more information on working with ranges in Google Sheets, see this guide on reading from and writing to range in Google Sheets using Apps Script.
4 steps to generate a Google Slides presentation template using data from a Google Sheets spreadsheetStep 1 — Create a Google Slides presentation template
Basic Google Sheets usage: You should know how to create spreadsheets, enter data, and navigate the Google Sheets interface. If you need a refresher, check out Google's Sheets tutorial.
How to create and run simple Apps Script scripts using the script editor in Google Sheets If you need a refresher, check out this guide on creating your first Apps Script.
What arrays are and how to use them in Apps Script For a review of arrays in Apps Script, see this article on arrays in Apps Script.
forEach loop in Apps Script If you need to brush up on the forEach loop, refer to this guide on forEach loop in Apps Script.
Reading from and writing to a range in Google Sheets using Apps Script For more information on working with ranges in Google Sheets, see this guide on reading from and writing to range in Google Sheets using Apps Script.
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.
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.
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 Extensions —> Apps Script.
Then replace the code in the editor with the code below.
Note
Remember to replace <PRESENTATION_ID>
in the code with the actual Id of your Google Slides presentation. You can get the Id from the URL of the presentation.
https://docs.google.com/presentation/d/<PRESENTATION_ID
>/edit
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
Congratulations! You've just learned how to harness the power of Google Apps Script to automate your presentation creation process. Let's recap what we've achieved:
We created a Google Slides template with placeholder variables.
We organized our data in a Google Sheets spreadsheet.
We wrote a simple yet powerful Apps Script to bridge the gap between our data and our presentation.
We ran the script to automatically populate our presentation with data from our spreadsheet.
This automation can save you countless hours, especially when dealing with repetitive presentations or reports. The beauty of this approach lies in its flexibility - you can easily modify the template or data to suit various needs.
Key Takeaways:Apps Script is a powerful tool for automating tasks across Google Workspace.
With just a few lines of code, you can create significant time-saving workflows.
This technique can be adapted for various use cases, from business reports to educational materials.
Next Steps:Experiment with different types of content in your presentations.
Try creating multiple slides or even multiple presentations from a single spreadsheet.
Explore other Apps Script capabilities, such as adding charts or images to your slides.
Learn about time-driven triggers to schedule your presentation generation.
Apps Script is a powerful tool for automating tasks across Google Workspace.
With just a few lines of code, you can create significant time-saving workflows.
This technique can be adapted for various use cases, from business reports to educational materials.
Experiment with different types of content in your presentations.
Try creating multiple slides or even multiple presentations from a single spreadsheet.
Explore other Apps Script capabilities, such as adding charts or images to your slides.
Learn about time-driven triggers to schedule your presentation generation.
Remember, automation is all about working smarter, not harder. Keep exploring, keep creating, and keep automating!
Hope you found this tutorial helpful. Thanks for reading!