0

I am using the Google API Python Client to replace text placeholders with generated data. In this example, I detect all instances of "bar" and replace them with "foo", in all slides. slides_service is instantiated with apiclient.discovery.build(...)

batch_requests_array = [
            {
                "replaceAllText": {
                    "replaceText": "foo",
                    "containsText": {
                        "text": "bar",
                        "matchCase": False
                    }
                }
            }
        ]

        batch_requests = {"requests": batch_requests_array}
        request = slides_service.presentations().batchUpdate(presentationId=slides_id, body=batch_requests)
        res = request.execute()

Now if bar has a highlight color, how can I remove that when I replace it with foo? I think I need to add a separate request to my batch requests array, but I have been scrolling up and down here without finding any clue.

For clarity, this is the highlight option I am talking about as it's presented in the UI enter image description here

1 Answer 1

1

To remove the highlight color of a text, you will have to update the backgroundColor. To give you an idea, this is how the request should look, this will set the background fully transparent:

highlightedTextRequest = [
    {
        "updateTextStyle": {
            "objectId": "objectId",
            "style": {
                "backgroundColor": {
                }
            },              
        "fields": "*"
        }
    }
]

Note: The objectId in the request, is the ID of the shape or table with the text to be styled.

References:

Sign up to request clarification or add additional context in comments.

1 Comment

thank you, I will try that out and come back to this post! Somewhat counter-intuitive that it's called background in the API but highlighting in the UI!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.