Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

open google doc by id

What I am trying to do is make a copy of a template doc, the append sheet data to the new file. I am using the doc URL as the id. However, when I try to access the file I am getting this error "Document is missing (perhaps it was deleted?) (line 21)" Line 21 is

    var templateid = "URL";
    var file = DocumentApp.openById(templateid);        

Can anyone advise on what the problem could be?

like image 815
user1070396 Avatar asked Feb 01 '13 00:02

user1070396


People also ask

How do I find a Google Docs ID?

Google Drive File ID is a unique identifier of the file on Google Drive. File IDs are stable throughout the lifespan of the file, even if the file name changes. To locate the File ID, right-click on the name of the file, choose the Get Shareable Link option, and turn on Link Sharing if needed.

How can I view a Google Doc anonymously?

Open an Incognito Browser Window With your Google Docs document set up to allow anonymous editing, you have two options. You can either sign out of your Google account and access the document again, or you can open a private browsing window (or incognito window).


1 Answers

The document id is not the URL of the document, but it is a UID generated when the document is created, e.g., it is the value of id after var id = createDocWithTable("doc with table").

You need to keep track of this id separately. If you have the document object, you can retrieve it with its getId() method. The ID is also encoded into the URL, so https://docs.google.com/document/d/3ckYOu8kuIfBzbu-Dtu9XwGHUnUJG32PK7wHe5xMv3VG/ has document id 3ckYOu8kuIfBzbu-Dtu9XwGHUnUJG32PK7wHe5xMv3VG

like image 137
Charles Stewart Avatar answered Oct 18 '22 20:10

Charles Stewart