4

Imagine a published Google Document. On the bottom I want an "Edit this document" link. Is it possible to do this automatically, somehow? Maybe with a macro or similar?

Edit: Just like on a Wiki page, where one always has an EDIT button to edit the Wiki page.

3
  • 1
    Do I understand you correctly: you want to automatically create links to the editing view to be visible in published view?
    – dnbrv
    Jan 30, 2012 at 14:36
  • @dnbrv Yes, that is correct. Just like on a Wiki page, where one always has an EDIT button to edit the Wiki page.
    – David
    Jan 30, 2012 at 15:46
  • The link returns "Sorry, the file that you request doesn't exists".
    – Rubén
    Mar 20, 2016 at 15:10

1 Answer 1

1

Short answer

The "Publish to the web" feature of Google Documents doesn't include an option to add the link to edit the source document so one of the several ways to add the link like Google Apps Script and Google Documents add-on, Google Sites Gadget, JavaScript, etc. should be used.

Extended answer

Since the URL to edit a document has the file ID than the published to the web URL there are lot of ways to add the a link to edit the document at the bottom.

URL of a published to the web Google Document:
https://docs.google.com/document/d/1ZyU97pNm0wDtOziWKnToUnjtAZarpnny_8eohF8-_F0/pub

URL given by the Share feature: https://docs.google.com/document/d/1ZyU97pNm0wDtOziWKnToUnjtAZarpnny_8eohF8-_F0/edit?usp=sharing

URL given by the Google Drive get a link feature and getUrl() method:
https://docs.google.com/open?id=1ZyU97pNm0wDtOziWKnToUnjtAZarpnny_8eohF8-_F0

File ID

1ZyU97pNm0wDtOziWKnToUnjtAZarpnny_8eohF8-_F0

Considering the above, in certain scenarios could be easier to add the link manually than to automate this task.

Example

The following Google Apps Script snippet adds the URL of the document at the end of it's body.

function appendUrl() {
  var doc = DocumentApp.getActiveDocument();
  var body = doc.getBody();
  var text = 'Edit this document';
  var url = doc.getUrl();
  body.appendParagraph(text).setLinkUrl(url);
}

The above is the same than copying the URL of the document and insert an hyperlink at the end of the document.

References

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.