2

Rename and paste code

Rename to templates.gs → Paste code:

templates.gs
// Add menu to Google Sheets
function onOpen() {
  SpreadsheetApp.getUi()
    .createMenu('Slide Generator')
    .addItem('Generate Slides', 'generateSlidesFromSheet')
    .addToUi();
}

Step 4: Configure IDs

1

Open main.gs

Click main.gs in the sidebar

2

Update CONFIG

Replace the 3 IDs in the CONFIG section (top of file):

const CONFIG = {
  TEMPLATE_ID: '1Ab2C...',      // ID from Slides Template
  DATA_SHEET_ID: '1Ab2C...',      // ID from Google Sheets
  OUTPUT_FOLDER_ID: '1Ab2C...',   // ID from Drive Folder
  SHEET_NAME: 'SlideData'
};

Note: Paste IDs inside the single quotes

Step 5: Run Script

1

Select function

Dropdown “Select function” → generateSlidesFromSheet

2

Click Run

Click the play button to run

3

Authorize

First time will show permission dialog → Select account → AdvancedGo to…Allow

Done! Slides will be created in your specified folder

Data Mapping

Column Placeholder Description
TITLE {{TITLE}} Slide title
POINT1POINT3 {{POINT1}} Bullet points
DATE {{DATE}} Date
KPI_DATA Auto CREATE TABLE Metric|Value|Metric|Value
CHART_TYPE Auto CREATE CHART COLUMN, PIE, LINE, BAR
CHART_DATA Label,Value|Label,Value
CHART_TITLE Chart title
ACTIVE TRUE = create, FALSE = skip
Example KPI_DATA: Revenue|25000|Profit|8000|Customers|150
Example CHART_DATA: Jan,80|Feb,95|Mar,110

Auto Create Table & Chart

1

KPI Table

When KPI_DATA column has data, script automatically creates table with:

  • Row 1: Metric names (bold)
  • Row 2: Corresponding values

Format: Metric1|Value1|Metric2|Value2|…

2

Chart

When CHART_TYPE column has data, script automatically creates chart:

  • COLUMN – Column chart
  • PIE – Pie chart
  • LINE – Line chart
  • BAR – Bar chart

Script handles: KPI Table and Chart are created from Sheets data, not just text replacement!

Slide Layout

Each slide will have this structure:

+————————–+
| Title (from template) |
| Points (from template) |
+————————–+
| KPI Table (auto) |
+————————–+
| Chart (auto) |
+————————–+

Handle Missing Data

Case How It’s Handled
POINT1 empty Shows [POINT1]
KPI_DATA empty No table created
CHART_TYPE empty No chart created
TITLE empty Skip row
ACTIVE = FALSE Skip row

Configuration IDs

Required: Replace the IDs in CONFIG before running
Component How to Get ID Example ID
TEMPLATE_ID Slides URL: /d/[ID]/edit 1abc123XYZ…
DATA_SHEET_ID Sheets URL: /d/[ID]/edit 1abc123XYZ…
OUTPUT_FOLDER_ID Drive URL: /folders/[ID] 1abc123XYZ…

After Running

1

Check Logs

After running, open Executions in sidebar to see logs:

  • Loaded: 12 rows – Number of data rows
  • Created: 10 slides – Number of slides created

2

Open Output Folder

Go to Google Drive → Open your folder → You will see:

  • Generated_Slides_2024-XX-XX/ – New folder created by date
  • Generated_Presentation – Final slides file
Each row in Sheets = 1 slide!
With 12 data rows → 12 slides are automatically generated
Return URL: The code returns the URL of the folder containing slides

Checklist

  • ☐ Create Google Sheets with complete columns
  • ☐ Create Slides Template with placeholders
  • ☐ Create Drive Folder
  • ☐ Open script.google.com → New project
  • ☐ Create 2 files: main.gs + templates.gs
  • ☐ Update CONFIG with 3 IDs
  • ☐ Run script + Authorize

Demo

Tags: