I am not able to find the right way to update text of existing objects using the google slides API.
Currently I am deleting the slide and creating it again.
I am not able to find the right way to update text of existing objects using the google slides API.
Currently I am deleting the slide and creating it again.
How about using presentations.batchUpdate
? By using this, the texts in the figures and on slide can be modified. The sample script is as follows. When you use this, please enable Slide API at API console and Advanced Google Services.
This sample modifies "sample text" on the slide of pageObjectIds
to "updated text".
var presentationId = "### presentationId ###";
var resource = {
"requests": [
{
"replaceAllText": {
"containsText": {
"text": "sample text"
},
"replaceText": "updated text",
"pageObjectIds": ["### pageObjectIds ###"] // If this is not defined, the text is searched from all slides.
}
}
]
};
Slides.Presentations.batchUpdate(resource, presentationId);
If I misunderstand your question, I'm sorry.
Inserting, deleting, or replacing text docs is what you're looking for.
There are two ways you can replace text in a presentation using the Slides API:
Global search and replace
Use ReplaceAllTextRequest to do a global search-and-replace throughout your presentation.
The Text Merging section of the Merging Data guide provides an example of how you can use this request type.
Replacing text within a shape
The Slides API lets you modify the text content of a shape. You can remove individual ranges of text, and you can insert text at a specific location.
Use InsertTextRequest and DeleteTextRequest to perform these operations.