I created a Google Sheet (XYZ) on my private Google Drive then shared that on a shared Google Drive. Then, I added an app script to XYZ and someone created several copies of XYZ in the shared Google Drive giving access to each employee to one copy of XYZ as Editor.
Following is the script I added to the Google sheet XYZ,
function onOpen() {
createEmptyMenu();
}
function createEmptyMenu() {
var menu = SpreadsheetApp.getUi().createMenu("⚙️ Admin Settings");
menu.addItem("Add Row", "addRowsAndMerge");
menu.addToUi();
}
function addRowsAndMerge() {
var sheetName = "Weekly Update - 2023";
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
sheet.insertRows(3, 3);
sheet.getRange("A3:A5").merge();
}
This script adds the Menu item to the Google sheet and should add 3 rows on top and merge them, on a specific tab named "Weekly Update - 2023" when the end user clicks on the Menu item.
Each time the user opens their respective copy of XYZ, the menu item gets added but when they click on that to add rows it shows this error, " ***Exception: You are trying to edit a protected cell or object. Please contact the spreadsheet owner to remove protection if you need to edit***."
When I use their sheet and click on the menu item it works and adds the rows.
Why is the script not working at the end user's end? How can I remove this so called protection?
I am grateful that you read my query. Please help.