保存文档而不关闭

时间:2019-09-12 21:11:46

标签: google-apps-script google-docs

如何在不先关闭saveAndClose()的情况下将当前文档另存为docx?我想从运行脚本的同一原始Google文档创建多个let d = { "message": "Failed", "NOTIFY": [{ "code": "400", "DATA": ["abc"], "message": "already in use only 1 data." }, { "code": "400", "DATA": ["ac"], "message": "already in use 1 data." }, { "code": "400", "DATA": ["pqs", "xyz", "sssd", "wer", "pop"], "message": "already in use with 5 data." }, { "code": "400", "DATA": ["abc", 'XYZ'], "message": "already in use with 2 data." } ] } 文件。

1 个答案:

答案 0 :(得分:0)

您可以使用URL提取将文档导出到docx:

function myFunction() {

 var doc_id = 'YOUR DOCUMENT ID';
 var url = 'https://docs.google.com/feeds/download/documents/export/Export?id=' + doc_id + '&exportFormat=docx';
 var options = {
  headers: {
   Authorization: "Bearer " + ScriptApp.getOAuthToken()
  },
   muteHttpExceptions: true
 }
 var response = UrlFetchApp.fetch(url, options);
 var doc = response.getBlob();
 DriveApp.createFile(doc).setName('myDocxFile1');
 DriveApp.createFile(doc).setName('myDocxFile2');
}