Search

Replace Text

Last Updated: Mar 15, 2021

Articles

Use this function to replaces an old text with new text in the Google Doc.

Syntax

Replace Text (document_id, old_text, new_text, private_key, client_email)

Parameters

Input Parameter Name Description
document_id Name of the document
old_text Text to be replaced
new_text New text to be updated
private_key Private key of the service account
client_email Email ID of the service account

Returns

Return Value Description
Output
  • On Success returns 1, Text replaced successfully
  • On Failure returns 0, Error Message

Sample

Replace Text (XYZ123, Travel, Commute, —–BEGIN PRIVATE KEY—–\nABCD\n—–END PRIVATE KEY—–, name@project-id.iam.gserviceaccount.com)

  • Uses the private key —–BEGIN PRIVATE KEY—–\nABCD\n—–END PRIVATE KEY—– to connect to the Email ID name@project-id.iam.gserviceaccount.com, replaces the text Travel with the text Cmmute in the Google Doc with ID XYZ123.
    Returns Text replaced successfully after replacing the text.

To view all the Google Docs functions, click here.

Did you find what you were looking for?