Google Slides
Stay organized with collections
Save and categorize content based on your preferences.
Create a new presentation
function
createPresentation
()
{
var
presentation
=
Slides
.
Presentations
.
create
({
"title"
:
"MyNewPresentation"
});
console
.
log
(
"Created presentation with ID: "
+
presentation
.
presentationId
);
}
Create a new slide
function
createSlide
(
presentationId
)
{
//
You
can
specify
the
ID
to
use
for
the
slide
,
as
long
as
it
's unique.
var
pageId
=
Utilities
.
getUuid
();
var
requests
=
[{
"createSlide"
:
{
"objectId"
:
pageId
,
"insertionIndex"
:
1
,
"slideLayoutReference"
:
{
"predefinedLayout"
:
"TITLE_AND_TWO_COLUMNS"
}
}
}];
var
slide
=
Slides
.
Presentations
.
batchUpdate
({
'requests'
:
requests
},
presentationId
);
console
.
log
(
"Created Slide with ID: "
+
slide
.
replies
[
0
]
.
createSlide
.
objectId
);
}
Read page element object IDs
function
readPageElementIds
(
presentationId
,
pageId
)
{
//
You
can
use
a
field
mask
to
limit
the
data
the
API
retrieves
//
in
a
get
request
,
or
what
fields
are
updated
in
an
batchUpdate
.
var
response
=
Slides
.
Presentations
.
Pages
.
get
(
presentationId
,
pageId
,
{
"fields"
:
"pageElements.objectId"
});
console
.
log
(
response
);
}
Add a new text box
function
addTextBox
(
presentationId
,
pageId
)
{
//
You
can
specify
the
ID
to
use
for
elements
you
create
,
//
as
long
as
the
ID
is
unique
.
var
pageElementId
=
Utilities
.
getUuid
();
var
requests
=
[{
"createShape"
:
{
"objectId"
:
pageElementId
,
"shapeType"
:
"TEXT_BOX"
,
"elementProperties"
:
{
"pageObjectId"
:
pageId
,
"size"
:
{
"width"
:
{
"magnitude"
:
150
,
"unit"
:
"PT"
},
"height"
:
{
"magnitude"
:
50
,
"unit"
:
"PT"
}
},
"transform"
:
{
"scaleX"
:
1
,
"scaleY"
:
1
,
"translateX"
:
200
,
"translateY"
:
100
,
"unit"
:
"PT"
}
}
}
},
{
"insertText"
:
{
"objectId"
:
pageElementId
,
"text"
:
"My Added Text Box"
,
"insertionIndex"
:
0
}
}];
var
response
=
Slides
.
Presentations
.
batchUpdate
({
'requests'
:
requests
},
presentationId
);
console
.
log
(
"Created Textbox with ID: "
+
response
.
replies
[
0
]
.
createShape
.
objectId
);
}
Format shape text
function
formatShapeText
(
presentationId
,
shapeId
)
{
var
requests
=
[{
"updateTextStyle"
:
{
"objectId"
:
shapeId
,
"fields"
:
"foregroundColor,bold,italic,fontFamily,fontSize,underline"
,
"style"
:
{
"foregroundColor"
:
{
"opaqueColor"
:
{
"themeColor"
:
"ACCENT5"
}
},
"bold"
:
true
,
"italic"
:
true
,
"underline"
:
true
,
"fontFamily"
:
"Corsiva"
,
"fontSize"
:
{
"magnitude"
:
18
,
"unit"
:
"PT"
}
},
"textRange"
:
{
"type"
:
"ALL"
}
}
}];
var
response
=
Slides
.
Presentations
.
batchUpdate
({
'requests'
:
requests
},
presentationId
);
}
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-20 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-20 UTC."],[[["\u003cp\u003eThe provided Google Apps Script code snippets demonstrate how to programmatically create and manipulate Google Slides presentations.\u003c/p\u003e\n"],["\u003cp\u003eThe code covers functionalities such as creating presentations and slides, reading element IDs, adding text boxes, and formatting text within those boxes.\u003c/p\u003e\n"],["\u003cp\u003eUsers can leverage these functions to automate presentation creation, customization, and content population, reducing manual effort and improving efficiency.\u003c/p\u003e\n"],["\u003cp\u003eEach function is independent and focuses on a specific task, allowing for flexibility in combining and using them to suit different use cases.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can adapt these examples to build more complex scripts for diverse slide manipulation scenarios within their applications or workflows.\u003c/p\u003e\n"]]],[],null,["# Google Slides\n\nCreate a new presentation\n-------------------------\n\n```gdscript\nfunction createPresentation() {\n var presentation =\n Slides.Presentations.create({\"title\": \"MyNewPresentation\"});\n console.log(\"Created presentation with ID: \" + presentation.presentationId);\n}\n```\n\nCreate a new slide\n------------------\n\n```gdscript\nfunction createSlide(presentationId) {\n // You can specify the ID to use for the slide, as long as it's unique.\n var pageId = Utilities.getUuid();\n\n var requests = [{\n \"createSlide\": {\n \"objectId\": pageId,\n \"insertionIndex\": 1,\n \"slideLayoutReference\": {\n \"predefinedLayout\": \"TITLE_AND_TWO_COLUMNS\"\n }\n }\n }];\n var slide =\n Slides.Presentations.batchUpdate({'requests': requests}, presentationId);\n console.log(\"Created Slide with ID: \" + slide.replies[0].createSlide.objectId);\n}\n```\n\nRead page element object IDs\n----------------------------\n\n```gdscript\nfunction readPageElementIds(presentationId, pageId) {\n // You can use a field mask to limit the data the API retrieves\n // in a get request, or what fields are updated in an batchUpdate.\n var response = Slides.Presentations.Pages.get(\n presentationId, pageId, {\"fields\": \"pageElements.objectId\"});\n console.log(response);\n}\n```\n\nAdd a new text box\n------------------\n\n```gdscript\nfunction addTextBox(presentationId, pageId) {\n // You can specify the ID to use for elements you create,\n // as long as the ID is unique.\n var pageElementId = Utilities.getUuid();\n\n var requests = [{\n \"createShape\": {\n \"objectId\": pageElementId,\n \"shapeType\": \"TEXT_BOX\",\n \"elementProperties\": {\n \"pageObjectId\": pageId,\n \"size\": {\n \"width\": {\n \"magnitude\": 150,\n \"unit\": \"PT\"\n },\n \"height\": {\n \"magnitude\": 50,\n \"unit\": \"PT\"\n }\n },\n \"transform\": {\n \"scaleX\": 1,\n \"scaleY\": 1,\n \"translateX\": 200,\n \"translateY\": 100,\n \"unit\": \"PT\"\n }\n }\n }\n }, {\n \"insertText\": {\n \"objectId\": pageElementId,\n \"text\": \"My Added Text Box\",\n \"insertionIndex\": 0\n }\n }];\n var response =\n Slides.Presentations.batchUpdate({'requests': requests}, presentationId);\n console.log(\"Created Textbox with ID: \" +\n response.replies[0].createShape.objectId);\n}\n```\n\nFormat shape text\n-----------------\n\n```gdscript\nfunction formatShapeText(presentationId, shapeId) {\n var requests = [{\n \"updateTextStyle\": {\n \"objectId\": shapeId,\n \"fields\": \"foregroundColor,bold,italic,fontFamily,fontSize,underline\",\n \"style\": {\n \"foregroundColor\": {\n \"opaqueColor\": {\n \"themeColor\": \"ACCENT5\"\n }\n },\n \"bold\": true,\n \"italic\": true,\n \"underline\": true,\n \"fontFamily\": \"Corsiva\",\n \"fontSize\": {\n \"magnitude\": 18,\n \"unit\": \"PT\"\n }\n },\n \"textRange\": {\n \"type\": \"ALL\"\n }\n }\n }];\n var response =\n Slides.Presentations.batchUpdate({'requests': requests}, presentationId);\n}\n```"]]