Auto Update Google Slides from Google Sheets

In this post, I will show you How to Auto Update Google Slides from Google Sheets using Google Apps Script.

To Be honest, Directly It’s Not Possible. But I have one idea to Auto Update Google Slides from Google Sheets

Approach to Auto Update Google Slides from Google Sheets

First Create a Google sheet.

Auto Update Google Slides from Google Sheets

After, Creating a Google sheet, Create a Table chart in Google sheets with the data. For creating a Chart click on chart icon in the menu of sheet

Auto Update Google Slides from Google Sheets

In the chart menu, We have to select a table chart

Auto Update Google Slides from Google Sheets

After that, We have to select the data range in the chart from the sheet. I select range A to B because of My data in Colum A and in Column B.

Auto Update Google Slides from Google Sheets

after That chart is created and the sheet looks like below. You can adjust its width and height and also hide the chart.
Copy the chart. double click on the chart there is three dots and copy the chart.

Auto Update Google Slides from Google Sheets

Create a Google Slides

Create a Google Slide and paste the copied chart. we do all these things to Auto Update Google Slides from Google Sheets

Auto Update Google Slides from Google Sheets

Google Slides will look like this

Auto Update Google Slides from Google Sheets

Open the script editor is google slides

Auto Update Google Slides from Google Sheets

Google Apps Script

  • In the script editor put the code as shown below.
  • After that refresh the Google Slides and In slide menu click on Update Charts > set trigger. when you click on this you have to authorize the code.
  • After authorization trigger will set and every minute slide data will refreshes
function onOpen() {
SlidesApp.getUi() // Or DocumentApp or FormApp.
    .createMenu('Update Charts')
    .addItem("Update now !!!!!", 'refreshCharts')
    .addSeparator()
    .addItem('Create Trigger', 'createTrigger')
    .addToUi();
}
function refreshCharts(){
  var gotSlides = SlidesApp.getActivePresentation().getSlides();
  for (var i = 0; i < gotSlides.length; i++) {
    var slide = gotSlides[i];
    var sheetsCharts = slide.getSheetsCharts();
    for (var k = 0; k < sheetsCharts.length; k++) {
      var shChart = sheetsCharts[k];
      shChart.refresh();
    }
  }
}
function createTrigger() {
  // Trigger every 1 minute
  ScriptApp.newTrigger('refreshCharts')
      .timeBased()
      .everyMinutes(1)
      .create();
}
Auto Update Google Slides from Google Sheets

finally, we can Auto Update Google Slides from Google Sheets

Leave a Reply