I know some JS and I have a fair amount of experience with VBA scripts for MSO, but I'm just starting to learn how to script google docs, and I'm having difficulty with the google scripting environment.
I created a doc on my google drive, and I am trying to log outputs in the code, but I get an error when I get the error TypeError: Cannot find function getBody in object Excel Download Macro Log File. (line 56, file "Code") when I try to run this code:
function logDataFromCode() {
var LogDoc = DriveApp.getFilesByName('Excel Download Macro Log File').next();
// Access the body of LogDoc, then add a paragraph with relevant data from script:
LogDoc.getBody()
.appendPageBreak()
.appendParagraph("[put variables to log here]");
}
Can someone please explain why I am getting this error?
LogDoc, what type of object is it?Logger.log(logDoc)LogDocis afileand you want adocument, try calling((Document)LogDoc).getBody()var doc = DocumentApp.openById(LogDoc.getId()); doc.getBody()?