Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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 '12 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 '12 at 15:46
    
The link returns "Sorry, the file that you request doesn't exists". – Rubén Mar 20 at 15:10

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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