如何将生成的PDF移动到Google云端硬盘中的特定文件夹

时间:2014-07-18 14:59:48

标签: pdf

以下是我希望此脚本执行的操作的主旨。

用户使用Google表单提交表单 表格记录到Google表格 工作表替换文本并从模板生成Google文档 模板被复制 PDF是从此模板创建的 PDF通过电子邮件发送 PDF将移至Google云端硬盘中的特定文件夹。

除了最后一步,我还能完成所有这些工作。有人可以帮助我们吗?我们正在将它用于学校,我们(IT)部门的任何人都不了解脚本。通过谷歌搜索和搜索,我走到了这一步。最后一步是让PDF移动到特定文件夹。

以下是当前代码:

// MacArthur High School
// Generic PLC Agenda Script
// Created 18 Jul 2014
// Author: Josh Patrick
// Decatur Public Schools #61

// Document Creation - replace docTemplate links with each template link on the PLC Drive. 

var docTemplate = "1DSFCE6mFZib0ZTVOgVqPbLYaRwjS-XNsnsZn5RZewsE"; 
var docName = "PLC Agenda";

// Form Functions (labeled identifiers for Form)

function onFormSubmit(e) {
  var TimeStamp = e.values [0]
  var MeetingDate = e.values [1];
  var MeetingTime = e.values [2];
  var MeetingLocation = e.values [3];
  var PLCFocus = e.values [4];
  var PlannedActions = e.values [5];
  var ResourcesNeeded = e.values [6];
  var AssignedEmail = "jwpatrick@dps61.org";

// Get document template, copy it as a new temp doc, and save the Doc’s id
var copyId = DocsList.getFileById(docTemplate)
.makeCopy(docName+' for '+ MeetingDate)
.getId();


// Open the temporary document
var copyDoc = DocumentApp.openById(copyId);

// Get the document’s body section
var copyBody = copyDoc.getActiveSection();

// Replacing Text with Form Information

copyBody.replaceText('keyMeetingDate', MeetingDate);
copyBody.replaceText('keyMeetingTime', MeetingTime);
copyBody.replaceText('keyMeetingLocation', MeetingLocation);
copyBody.replaceText('keyPLCFocus' , PLCFocus);
copyBody.replaceText('keyPlannedActions' , PlannedActions);
copyBody.replaceText('keyResourcesNeeded' ResourcesNeeded);


// Copy Document and Save

copyDoc.saveAndClose();

// Generate PDF  
var pdf = DocsList.getFileById(copyId).getAs("application/pdf");

// Email
var subject = "ELA PLC Agenda for " + MeetingDate ;
var body = "Attached is the PDF copy of the ELA PLC Agenda for " + MeetingDate;
MailApp.sendEmail(AssignedEmail, subject, body, {htmlBody: body, attachments: pdf});

// Delete Temporary Document
DocsList.getFileById(copyId).setTrashed(true);
}

****我想将其移至Google云端硬盘中的特定文件,而不是删除临时文档。我查了脚本帮助,但我认为我没有正确完成。我可以把它发送到copydoc,但我不能让它移动到正确的文件夹。

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:1)