あなたはクラスの保護を使用することができます。https://developers.google.com/apps-script/reference/spreadsheet/protectionあなたが試すことができます上記のリンクから適応
:
function pro(){
var sheet = SpreadsheetApp.getActiveSheet();
var protection = sheet.protect().setDescription('Sample protected sheet');
// Ensure the current user is an editor before removing others. Otherwise, if the user's edit
// permission comes from a group, the script will throw an exception upon removing the group.
var me = Session.getEffectiveUser();
protection.addEditor(me);
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
//YOUR CODE TO RUN
SpreadsheetApp.flush();
protection.remove();
}
EDIT
これは私のために働きました:
function onEdit(){
//Adapted from: https://developers.google.com/apps-script/reference/spreadsheet/protection
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[0];
var me = Session.getActiveUser().getEmail();
if (me != 'owner email'){
var protection = sheet.protect().setDescription('Sample protected sheet');
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
//YOUR CODE TO RUN
SpreadsheetApp.flush();
protection.remove();
}
}
何が起こっているのかを説明し、スクリプトの実行が終了するとプログラムで閉じられる、非表示のUIダイアログを使用することをお勧めします。 –