I am writing a google apps script that places the paragraphs of one document into a dictionary, then inserts them into a set of other documents based on certain criteria. The paragraphs are extracted like so:
var totalElements = doc.getNumChildren();
for( var j = 0; j < totalElements; ++j ) {
var element = doc.getChild(j).copy();
var type = element.getType();
// logic to add element to dictionary
}
Later, once the location a paragraph should be inserted is found, it is inserted via the insertParagraph() function:
body.insertParagraph(paragraphIndex, element);
This works fine, except for the fact that some paragraphs have comments attached to them that need to be copied along with them, and this method does not keep comments attached to their elements. Is there any way to implement this? Thanks for any help!