Introduction

Manually creating presentations from spreadsheet data can be time-consuming and tedious. Google Apps Script (GAS) allows you to automate this process, turning your data into stunning Google Slides presentations with ease.

This article will guide you through the steps of creating an intermediate-level script that generates Google Slides from your Google Sheets data, saving you time and ensuring consistency.

The sample codes provided in this article are just starting points to show you what is possible with GAS. We recommend that you dive deeper into the capabilities of GAS to fully leverage its potential and customise scripts to suit your specific needs.

If you are a complete beginner to Google Apps Script, we recommend to take a read on our Beginner’s Guide to Google Apps Script first before diving into this post.

Why Automate Google Slides Generation?

Automating the generation of Google Slides from spreadsheet data offers several benefits:

  • Efficiency: Quickly create presentations without manual data entry.
  • Consistency: Ensure uniformity in your presentations by using standardised templates and data.
  • Productivity: Free up your time for more critical tasks by automating repetitive work.
  • Scalability: Easily update presentations as data changes, without starting from scratch.

Steps to Automate Google Slides Generation

1. Open Google Sheets:

2. Prepare Your Data:

  • Ensure your spreadsheet has the data you want to include in the slides.
  • For example, use the first column for slide titles and the second column for slide content.
Ensure your spreadsheet has the data you want to include in the slides

3. Open Script Editor:

  • In the Google Sheets document, click on Extensions in the menu.
  • Select Apps Script. This will open the Apps Script editor in a new tab.

4. Create a New Project:

  • In the Apps Script editor, delete any existing code.
  • Copy and paste the following script into the code editor:
Copy Script
Copy Script

5. Save the Project:

  • Give your project a relevant name, for example, “Slides Generator”.
  • Click on the floppy disk icon to save the project.

6. Add the Custom Menu Code:

  • Ensure the onOpen function is included in the script to create a custom menu in Google Sheets.

7. Refresh Google Sheets:

  • Close the Apps Script editor tab.
  • Refresh the Google Sheets document to see the new custom menu.

8. Run the Script from the Custom Menu:

  • In your Google Sheets document, you will see a new menu item called “Slides Utilities” in the menu bar.
  • Click on Slides Utilities and select Generate Slides from Sheet.
Find “Slides Utilities” by Refreshing the Page

9. View the Generated Slides:

  • The script will create a new Google Slides presentation with slides generated from your spreadsheet data.
  • Check your Google Drive for the new presentation titled “Generated Presentation”.
Slides Generated Successfully Notice
Generated Presentation in Google Drive

Script Explanation

1. Reading Data from Google Sheets:

  • The script opens the active spreadsheet and reads the data from the active sheet.

2. Creating a Google Slides Presentation:

  • A new Google Slides presentation is created using SlidesApp.create().

3. Generating Slides:

  • The script loops through the rows of data, creating a new slide for each row. The first column is used as the slide title, and the second column is used as the slide content.

4. User Notification:

  • After generating the slides, the script displays an alert to the user indicating the slides were generated successfully.

Handling Errors with Gen AI

If you encounter errors while running the script, you can leverage Gen AI to help troubleshoot and fix the issue, ChatGPT can be particularly helpful in these situations:

  • Describe the Error: Provide a detailed description of the error you encountered.
  • Paste Error Code: Copy and paste the error code or message into your prompt.
  • Request a Fix: Ask the AI to help resolve the error, providing context and any relevant code snippets.

Example Prompt for Troubleshooting:

I encountered the following error while running my Google Apps Script: “TypeError: Cannot read property ‘getDataRange’ of null”. Here is the relevant part of my code:

Copy Script
Copy Script

Please help me troubleshoot and fix this error.

Conclusion

Automating the creation of Google Slides from spreadsheet data using Google Apps Script can significantly enhance your productivity and ensure consistency in your presentations.

By following the steps outlined in this article, you can easily generate slides from your data, saving time and effort.

If you encounter any issues, Gen AI tools like ChatGPT are available to help you troubleshoot and refine your scripts. Have fun automating!

By Ali Reza Azmi

Founder & Consultant @ Twenty-Four Consulting

By Ali Reza Azmi

Founder & Consultant @ Twenty-Four Consulting

Automation can be Super EASY, and FREE.

With Google Apps Script & Gen AI, you don't need to be a coder to automate anymore!

Watch our demo, download our free cheat sheet, and join the waitlist today.

Google Apps Script Waitlist Image

Related Posts