auto share with wmail (menu in the sheet) copy and paste

PHOTO EMBED

Tue Jan 31 2023 10:30:48 GMT+0000 (Coordinated Universal Time)

Saved by @ash1i #google

function shareActive() {
  var ss = SpreadsheetApp.getActive();
  var sheet = ss.getActiveSheet();

  var newSheet = SpreadsheetApp.create("New Sheet");
  var id = newSheet.getId();
  var open = SpreadsheetApp.openById(id);
  
  var copy = sheet.copyTo(open);

  var ui = SpreadsheetApp.getUi();
  var user = ui.prompt('Enter user email address', ui.ButtonSet.OK_CANCEL);

  if (
    user.getSelectedButton() == ui.Button.OK
  ) {
  var email = user.getResponseText()
  }

  DriveApp.getFileById(id).addEditor(email);
}

function onOpen(e) {
  SpreadsheetApp.getUi()
      .createMenu("Share Sheet")
      .addItem('Active Sheet', 'shareActive')
      .addToUi();
}
content_copyCOPY