简体   繁体   English

如何允许用户运行宏来编辑他们没有“编辑”权限的范围或工作表?

[英]How to allow users to run a macro which edits a range or sheet they don't have 'edit' permissions to?

I have made a macro that takes a set of input data, transfers it to a master data table, graphs trend lines of the data, and then clears the data entry sheet. 我制作了一个宏,该宏接受一组输入数据,将其传输到主数据表,对数据的趋势线进行绘制,然后清除数据输入表。 All sheets are protected to avoid employees from changing or deleting data that has already been entered and only the cells which require data entry are available for editing by the employees who I've shared the sheet with. 所有工作表都受到保护,以避免员工更改或删除已经输入的数据,并且与我共享工作表的员工只能编辑需要输入数据的单元格。 The macro works well if I try to run it but if another employee attempt to run the macro they get an error stating they don't have permission to edit certain ranges. 如果我尝试运行该宏,则该宏运行良好,但如果另一名员工尝试运行该宏,则会收到错误消息,指出他们无权编辑某些范围。

When I wrote the Excel macro for the same task I was able to unlock the sheets up front, transfer the required data, and then re-lock the sheets but can't figure out how to replicate this type of behavior in Google Apps Script. 当我为同一任务编写Excel宏时,我能够预先解锁工作表,传输所需的数据,然后重新锁定工作表,但无法弄清楚如何在Google Apps脚本中复制这种行为。

The Protection class on the Google Developers page did not prove to be helpful, since I kept getting an error saying the function protect could not be located in the Object spreadsheet. Google开发人员页面上的Protection类没有被证明是有帮助的,因为我一直收到错误消息,指出在对象电子表格中找不到保护功能。 I also tried the addEditor function without much luck. 我也尝试了addEditor函数,但运气不佳。 This is my first Google Apps Script and I've been trying to learn as I go but this project is proving difficult. 这是我的第一个Google Apps脚本,我一直在尝试学习,但是事实证明该项目很困难。

Thank you to @Tedinoz for helping me realize you can rename the onEdit function so long as you designate 'e' as a function input. 感谢@Tedinoz帮助我意识到只要将“ e”指定为函数输入,就可以重命名onEdit函数。 I was able to use an Installed Trigger on the sheet set to run RenamedonEdit(e) whenever the sheet is edited. 每当工作表被编辑时,我就可以在工作表集上使用“安装的触发器”来运行RenamedonEdit(e)。

暂无
暂无

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

相关问题 如何允许用户通过脚本编辑受保护范围? - How to allow users to edit protected range through script? 如何将变更事件回滚到Google工作表或仅禁止变更事件但允许用户进行编辑? - How to roll-back change events to a Google sheet or disallow only change events but allow edit rights to users? 如何允许谷歌工作表中的共享用户运行访问受保护工作表的脚本 - How to allow shared users in google sheets to run script that accesses protected sheet 在第一次编辑脚本运行后锁定单元格的值,并且不为其他编辑更新单元格值 - Lock the value of a cell after first edit script running and don't update the cell value for other edits 进行编辑后,如何将范围从一个Google表格复制到另一个表格? - How do I copy a range from one Google Sheet to another when edits are made? Google 表格 - 允许用户在受保护范围内运行脚本 - Google Sheets - Allow Users to run scripts on a protected range Google Sheet App Script 保护范围并允许基于电子邮件的编辑,但从编辑权限中排除少数列 - Google Sheet App Script Protect Range & Allow Editors Based on Email But Exclude Few Columns From Edit Rights 仅允许用户在使用“仅查看”类型共享时编辑特定范围 - Only allow users to edit a specific range whilst using a 'view only' type share 允许用户对Google表格进行更改,但这些更改不适用于其他用户 - Allow a user to make changes to a google sheet, but have these changes not apply to other users 不允许我保存对 appsscript.json 的编辑 - Won't allow me to save edits to appsscript.json
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM