私は質問に直接飛びます。私はいくつかの個々のブックに正しい情報を(質問/インポート範囲を介して)提供する多くの情報を持つメインのワークブックを持っています。私は、毎週メインワークブックを更新し、次のコードで毎週、個々のワークブックのための新しいシートを作成します。このコードは、すべての個々のワークブックに二つの新しいシートを作成するには完璧に動作
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var pasteSheet = [ {name: "Paste Sheet", functionName: "copySheet"}];
ss.addMenu("Copy to Spreadsheets", pasteSheet);
}
function copySheet() {
var source = SpreadsheetApp.getActiveSpreadsheet();
var sheet = source.getSheets()[0];
var sheet2 = source.getSheets()[1];
var sourceFile = DriveApp.getFileById(source.getId());
var sourceFolder = sourceFile.getParents().next();
var folderFiles = sourceFolder.getFiles();
var thisFile;
while (folderFiles.hasNext()) {
thisFile = folderFiles.next();
if (thisFile.getName() !== sourceFile.getName()){
var currentSS = SpreadsheetApp.openById(thisFile.getId());
sheet.copyTo(currentSS);
sheet2.copyTo(currentSS);
currentSS.getSheets()[currentSS.getSheets().length-2].setName('W6');
currentSS.getSheets()[currentSS.getSheets().length-1].setName('W6 ISSUES');
}
};
}
。
私の問題:私は、このスクリプトを実行する際にさまざまな方法で保護を組み込むよう取り組んできました。私が必要とするのは、個々のシートを保護することです(W6とW6の問題)。最初のW6はA3:A20の範囲を除いて完全に保護されている必要があります。ここでは、個々のシートの所有者に編集を許可する必要があります。 「W6問題」は完全に保護されるべきである。
これを行うにはどうすればいいですか?どんな助けもありがとう。
ありがとう! 100回のようなそのページにあり、最終的に私の答えが見つかりました '' // B2:C5以外のアクティブなシートを保護してから、エディタのリストから他のすべてのユーザを削除してください。 var sheet = SpreadsheetApp.getActiveSheet(); var protection = sheet.protect()。setDescription( 'サンプル保護シート'); var unprotected = sheet.getRange( 'B2:C5'); protection.setUnprotectedRanges([unprotected]); '' –