2016-07-27 27 views
0

我试图通过Google脚本锁定工作表。我想将此脚本锁定给所有用户。 我'用我在文件中发现:https://developers.google.com/apps-script/reference/spreadsheet/protection如何使用Google脚本为当前用户锁定工作表

// Protect range A1:B10, then remove all other users from the list of editors. 
var ss = SpreadsheetApp.getActive(); 
var range = ss.getRange('A1:B10'); 
var protection = range.protect().setDescription('Sample protected range'); 

// 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); 
} 

的问题是,应该锁定片的剧本是由应该看到锁定表用户跑了。

我的问题是:如何使用Google脚本锁定当前用户的工作表?

回答

1

不要以为你能做到这一点..我试过但没有工作。 在我看来,访问是由用户给出的,因此你不能限制用户自己启动/运行脚本。这有点棘手

+0

这不提供问题的答案。一旦你有足够的[声誉](http://stackoverflow.com/help/whats-reputation),你将能够[评论任何职位](http://stackoverflow.com/help/privileges/comment);相反,[提供不需要提问者澄清的答案](http://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-c​​an- I-DO-代替)。 - [来自评论](/评论/低质量帖/ 13164951) –

+0

酷thnx ..新的网站..欣赏反馈 – Pushkar

相关问题