Prevent User from adding sheets - google sheets

Поделиться
HTML-код
  • Опубликовано: 10 авг 2022
  • code here
    docs.google.com/document/d/1h...
    Photo by cottonbro: www.pexels.com/photo/woman-ho...

Комментарии • 27

  • @nourhanebadlis3444
    @nourhanebadlis3444 Год назад

    جزاك الله بألف خير

  • @encikmohdrazifibrahim6243
    @encikmohdrazifibrahim6243 Год назад

    thank you for sharing

  • @jayasri-ft8040
    @jayasri-ft8040 2 года назад

    Super idea, thankyou

    • @askfarouk
      @askfarouk  2 года назад

      Thanks for the positive comment

  • @lucianopessanha7437
    @lucianopessanha7437 Год назад +1

    Thanks.

  • @user-kn2rb4cs6v
    @user-kn2rb4cs6v Месяц назад +1

    I like the idea. But mobile devices don't run SCRIPTS. I have written scripts for years. Unfortunately you can only do this on Desktop computer. And it doesn't stop users from creating sheets. You have to manually delete them; delete them by opening the sheet on a Desktop computer.
    :{

  • @ashaharika9565
    @ashaharika9565 6 месяцев назад

    How to reverse it.
    Kindly help

  • @lucianopessanha7437
    @lucianopessanha7437 Год назад +1

    how do I make hidden tabs remain hidden (hide.sheet)? In my test it deletes the hidden tabs and if I declare them it activates them so as not to delete them.

    • @askfarouk
      @askfarouk  Год назад +1

      Hi
      Not supposed to be deleted, but let me check

    • @arianeg6004
      @arianeg6004 Год назад

      @@askfarouk Hi, thanks for your idea. Have you perhaps already resolved for those deleted hidden tabs?

    • @Account-gd6qu
      @Account-gd6qu Год назад

      This is also my concern ty

  • @Accountingpapers
    @Accountingpapers 6 месяцев назад

    مرحبا استاذ احمد، كيف يمكن ان نجعل من الشيتات المخفية / مخفية لدى المستخدم ولايمكن له الاطلاع عليها، ايضا كيف يمكن منع المستخدم من اضافة شيت جديد للملف ...شكرا.

  • @aymanabuelmaged7230
    @aymanabuelmaged7230 2 года назад

    A very cool idea, as usual, excellence and creativity, but what if I have more than one sheets?

    • @askfarouk
      @askfarouk  Год назад

      Thanks 🙏 Mr.Ayman

    • @askfarouk
      @askfarouk  Год назад +1

      Same idea make i start from the number of sheets

    • @aymanabuelmaged7230
      @aymanabuelmaged7230 Год назад

      @@askfarouk appreciate

    • @thaycuongtin8479
      @thaycuongtin8479 Год назад +1

      you can change the value of i in the for loop. docs.google.com/document/d/1kEUE1XOnwk03jbgBsVPAjJDa2xbikZeLN4hhgwfAdzA/edit?usp=sharing

    • @flukturr
      @flukturr 9 месяцев назад

      Error
      TypeError: Cannot read properties of null (reading 'activate')
      onOpen @ Delete sheets.gs:12 :( @@thaycuongtin8479

  • @thaycuongtin8479
    @thaycuongtin8479 Год назад +1

    It doesn't work on mobile phones, as Iphone. Thank you for sharing!

    • @askfarouk
      @askfarouk  Год назад

      I can't confirm as i am not apple friendly user

  • @Desmog
    @Desmog Год назад

    // Deletes any tab named "SheetN" where N is a number
    function onOpen() {
    var newSheetName = /^Sheet[\d]+$/
    var ssdoc = SpreadsheetApp.getActiveSpreadsheet();
    var sheets = ssdoc.getSheets();
    // is the change made by the owner ?
    if (Session.getActiveUser().getEmail() == ssdoc.getOwner().getEmail()) {
    return;
    }
    // if not the owner, delete all unauthorised sheets
    for (var i = 0; i < sheets.length; i++) {
    if (newSheetName.test(sheets[i].getName())) {
    ssdoc.deleteSheet(sheets[i])
    }
    }
    }
    This will automatically delete any new sheet that was not created by the owner

    • @kamaljeetsingh8919
      @kamaljeetsingh8919 Год назад

      the code did not work, I have just copy and paste the code without any modification

    • @Desmog
      @Desmog Год назад

      @@kamaljeetsingh8919 did you run the script?
      If yes, open the sheet on a PC and see the magic. ( it's not deleting on mobile phones for whatever reason)

    • @user-kn2rb4cs6v
      @user-kn2rb4cs6v Месяц назад

      @@Desmog Android and "mobile devices" don't run javascript. It really stinks! But you can only do this on a Desktop computer.

    • @Pizzacaviar
      @Pizzacaviar 18 дней назад +1

      @@Desmog Hey Desmog I have been trying to run this script for the past months and I cannot get it to work. Trying to do this as I manage the schedule of a non-profit but my work is keeping me busy and I don't know much about code. I am thinking this might be due to the fact that my Google Spreadhseet is in French hence newly created sheets are named "feuille XXX" where x is a number. I tried changing 'sheet' by 'feuille' in the script but that does not work. I recently changed the language of the Googlesheet doc to English but still no luck. Any idea what's up ? Thanks !

    • @Desmog
      @Desmog 17 дней назад

      @Pizzacaviar
      For your language, please use the updated version below:
      function onOpen() {
      var newSheetName = /^Feuille[\d]+$/;
      var ssdoc = SpreadsheetApp.getActiveSpreadsheet();
      var sheets = ssdoc.getSheets();
      // If the change is made by the owner, exit the function
      if (Session.getActiveUser().getEmail() == ssdoc.getOwner().getEmail()) {
      return;
      }
      // If not the owner, delete all unauthorised sheets
      for (var i = 0; i < sheets.length; i++) {
      if (newSheetName.test(sheets[i].getName())) {
      ssdoc.deleteSheet(sheets[i]);
      }
      }
      }
      How to Set Up the Trigger (in French):
      1. Ouvrez le document Google Sheets.
      2. Allez dans `Extensions > Apps Script`.
      3. Copiez et collez le script dans l'éditeur de script.
      4. Enregistrez le script.
      5. Allez dans `Éditer > Déclencheurs du projet actuel`.
      6. Cliquez sur `+ Ajouter un déclencheur`.
      7. Sélectionnez `onOpen` dans la liste déroulante des fonctions à exécuter.
      8. Choisissez `À partir du tableur` pour la source de l'événement.
      9. Sélectionnez `À l'ouverture` pour le type d'événement.
      10. Enregistrez le déclencheur.