Wednesday, 14 August 2013

How to get a document object from a file object in a Google-Apps Script

How to get a document object from a file object in a Google-Apps Script

My problem is that I have a number of Google documents (docs) and each has
a table of contents. I want to grab the TOC's and place them in another
document. This should be easy, but I have run into a snag.
I can grab all of files in a folder with: var folder =
DocsList.getFolder('yourfolder'); var contents =
folder.getFilesByType(DocsList.FileType.DOCUMENT); This gives me an array
of files as the variable 'contents'
Great.
I also know that var TOC =
doc.getAs(DocumentApp.ElementType.TABLE_OF_CONTENTS)
The problem is that I cannot figure out how to get a document object from
a file object or alternately how to get an array of documents in a folder
rather than an array of files.
I have searched for an answer and not only on this site. If anyone can
help, I would appreciate it very much

No comments:

Post a Comment