17

Is it possible to programmatically edit a native Google document, say to make certain words bold or hyperlinks? I know I can export that to some format like DOC or ODT, do the changes and put back. But tried this way manually and saw that I lost the exact look. Could not find any API or object model for native Google docs, although seems there is something for the spreadsheets.

Pablo Claus
  • 5,760
  • 3
  • 27
  • 38
Sanjay
  • 8,355
  • 2
  • 43
  • 60

1 Answers1

15

Unfortunately it is not possible to programmatically edit Google Documents (Google's Word Processor document) using a REST API. Only Google Spreadsheet offers such an API at the moment.

You could try Google Apps Script: https://developers.google.com/apps-script/ it is a hosted scripting environment and it offers a Google Documents Service that allows you to edit and manage existing Google Documents.

Lastly you could always upload a document using an open format such as RTF and have it converted to a native Google Documents using the Google Drive API.

Nicolas Garnier
  • 11,836
  • 2
  • 40
  • 39
  • I tried apps-script - worked nicely. Combined with [time driven trigger](https://developers.google.com/apps-script/execution_methods#time-driven_trigger), I think I can have my requirement met. Thanks! – Sanjay Jul 23 '12 at 10:19
  • 1
    Dear @Nivco, I can't find how I can upload a Word document using Google Drive API, and make it to convert to Google Doc format. Can you guide me please? – Saeed Neamati Jul 16 '15 at 18:54
  • Hi @SaeedNeamati, you can use the insert method from the Drive API, with the "convert" parameter in order to convert a Word document to a Google Docs format: https://developers.google.com/drive/v2/reference/files/insert - [See also this SO post](https://stackoverflow.com/questions/12480376/is-it-possible-to-update-a-google-docs-file-with-data-from-a-microsoft-office-fi?rq=1) – Quent1V Jul 19 '17 at 11:10