Merging the bodys of three google docs documents via google script -
What I try to do is the following: I would like to merge the body (with formatting, table, image etc.) ) I searched the web for hours of three different Google Documents, but I could not find any solutions that I was able to work on.
First of all, fill
Best look, the code is like this:
function merge docs () {var docIDs = ['list-of', 'documents', 'id', 'you should do something']; Var baseDoc = DocumentApp.openById (docIDs [0]); Var body = baseDoc.getActiveSection (); (Var i = 1; i & lt; docIDs.length; ++ i) {var other body = DocumentApp.openById (docIDs [i]). GetActiveSection (); Var totalElements = otherBody.getNumChildren (); (Var J = 0; J & lt; Total Elements; ++ J) for {var element = otherBody.getChild (j) .copy (); Var type = element.getType (); If (type == DocumentApp.ElementType.PARAGRAPH) body.appendParagraph (element); And if (type == DocumentApp.ElementType.TABLE) body.appendTable (element); Else if (type == DocumentApp.ElementType.LIST_ITEM) body.appendListItem (element); And then insert a new error ("According to the doctor, this type can not appear in the body:" + type); }}} If some element types are not in the list then you can easily add them in the following logic.
Comments
Post a Comment