[英]Naming a New Sheet with Google Scripts from a specific cell on a Google Sheet
trying to figure out how to give a new sheet that is copied into a folder a specific name each time from a button script.试图弄清楚如何为每次从按钮脚本复制到文件夹中的新工作表提供特定名称。 The specific name would come from a specific cell each time.
特定名称每次都来自特定单元格。
Here's the current code being used and the New Sheet is what I'm trying to have named from cell B3 on a specific spreadsheet each time.这是当前正在使用的代码,新工作表是我每次尝试从特定电子表格上的单元格 B3 中命名的内容。 No idea how to do this, it just names it NEW SHEET each time and then errors out when I try to do B3.
不知道如何做到这一点,它每次都将其命名为 NEW SHEET,然后在我尝试执行 B3 时出错。
function cloneGoogleSheet() {
var destFolder = DriveApp.getFolderById("Folder Name");
DriveApp.getFileById("Folder Name").makeCopy('NEW SHEET', destFolder);
SpreadsheetApp.getActive().getSheetByName('NEW SHEET').setName('Specific Sheet!B3')
}
Any help is appreciated!任何帮助表示赞赏!
function cloneGoogleSheet() {
const ss = SpreadsheetApp.getActive();
const sh = ss.getActiveSheet();
const name = sh.getRange('A1').getDisplayValue();
const destFolder = DriveApp.getFolderById("Folder Id");
DriveApp.getFileById("file id").makeCopy(name, destFolder);
}
Get used to using file id's and not names.习惯使用文件 ID 而不是名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.