简体   繁体   English

尝试将Google表格备份或复制到特定文件夹,然后继续获取“找不到方法addFile(Folder)。 (第25行,文件“ XXXXX”)

[英]Trying to backup or copy a Google Sheet into a specific folder and keep getting “Cannot find method addFile(Folder). (line 25, file ”XXXXX“)”

I keep getting the following error with my code. 我的代码不断出现以下错误。

"Cannot find method addFile(Folder). (line 25, file "XXXXX")" “找不到方法addFile(Folder)。(第25行,文件“ XXXXX”)”

Can anyone help me with this? 谁能帮我这个?

Thank you so much! 非常感谢!

function manualBackup() {
var folder, backup;
folder = DriveApp.getFolderById("0B49siU2r7QqYSE9ZeHJCM2FKR2c");
backup = DriveApp.getFileById(SpreadsheetApp.getActiveSpreadsheet().getId()).makeCopy(SpreadsheetApp.getActiveSpreadsheet().getName() + "_Backup_Copy");
backup = DriveApp.addFile(folder); // This is line 25 with the issue
backup.removeFromFolder(DocsList.getRootFolder());
}

Tried and tested this code: 尝试并测试了以下代码:

function manualBackup() {
  var folder = DriveApp.getFolderById("0B3M-kyknQTApWG1STzBhaFBEMVE");
  var file = DriveApp.getFileById("1mBWb98eap8xyAjlahCV8TM3FVKabvoM3OdesICRdERg");
  var name = file.getName() + "_Backup_Copy";
  file.makeCopy(name ,folder);
}

Seems that addFile() or makeCopy() methods will be working only for folders where you have write permission granted. 似乎addFile()或makeCopy()方法仅适用于已授予写许可权的文件夹。 Tried this code on a folder which is created by me in my Drive. 在我在云端硬盘中创建的文件夹中尝试了此代码。

Hope that helps! 希望有帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将Google工作表复制到特定文件夹 - copy google sheet into specific folder 尝试从 Google 表格中的 URL 将文件的副本保存到特定的 Google Drive 文件夹 - Trying to save a copy of a file to specific Google Drive folder, from URLs in a Google Sheet 尝试从Google云端硬盘中的特定文件夹复制特定文件 - Trying to copy specific file from specific folder in Google Drive 找不到方法(类) - Cannot find method (class)addFile 将工作表副本保存到特定文件夹 - Saving a copy of a sheet to a specific folder 用于将一张工作表复制到Google云端硬盘中特定文件夹中的各种电子表格的脚本 - A script to copy one sheet to various spreadsheets in a specific folder in Google Drive Google 脚本创建新的工作表文件并将其移动到特定文件夹然后将活动工作表中的内容和 2 个标签复制到新创建的文件 - Google script Create new sheet file and move it to a specific folder Then copy the contents and 2 tabs from the active sheet to the newly created file 将工作表从 SpreadSheet 文件复制到 Google 云端硬盘文件夹 - Copy a sheet from a SpreadSheet file to a Google Drive folder 将 google sheet 复制到 google drive 文件夹中 - Make a copy of google sheet into google drive folder 有没有办法将特定工作表从一个工作簿复制到特定(和不同)文件夹作为谷歌中自己的独立工作表? - Is there a way to copy a specific sheet from one workbook to a specific (and different) folder as its own stand alone sheet in google?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM