Note: The other languages of the website are Google-translated. Back to English
Vpiši se  \/ 
x
or
x
Registracija  \/ 
x

or

Kako onemogočiti ali ne dovoliti možnosti Shrani in shrani kot v Excelu?

Ko kliknemo funkcijo Shrani ali Shrani kot, se običajno spremenjeni podatki v delovnem zvezku shranijo hkrati. Toda včasih drugi uporabniki, ko preberejo datoteko, ne morejo spreminjati in shraniti vaše datoteke Excel. V tem članku je opisana metoda VBA za onemogočanje možnosti Shrani in shrani kot v Excelu.

Onemogočite možnosti Shrani in shrani kot s kodo VBA


Onemogočite možnosti Shrani in shrani kot s kodo VBA

Zaženete lahko spodnjo kodo VBA, da onemogočite možnosti Shrani in shrani kot v Excelu.

1. V delovnem zvezku morate onemogočiti funkcije Shrani in shrani kot, pritisnite druga + F11 tipke hkrati, da odprete Microsoft Visual Basic za aplikacije okno.

2. V Ljubljani Microsoft Visual Basic za aplikacije okno, dvokliknite ThisWorkbook v levo vrstico kopirajte in prilepite spodnji VBA 1 v okno Code in kliknite na Shrani . Oglejte si posnetek zaslona:

VBA 1: onemogočite možnosti Shrani in shrani kot v Excelu

Private Sub Workbook_BeforeClose(Cancel As Boolean)
    ThisWorkbook.Saved = True
End Sub

3. Na odprtju Shrani kot izberite mapo, v katero želite shraniti delovni zvezek, poimenujte delovni zvezek, kot ga potrebujete, in izberite Excelov delovni zvezek z omogočeno makro Iz Shrani kot vrsto spustnega seznama in na koncu kliknite Shrani gumb.

4. Zdaj kopirajte in prilepite spodnji VBA 2 v ThisWorkbook okno kode. Oglejte si posnetek zaslona.

VBA 2: onemogočite možnosti Shrani in shrani kot v Excelu

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim xName As String
xName = "CancelBeforeSave"

If Not Evaluate("=ISREF('" & xName & "'!A1)") Then
    Sheets.Add(after:=Worksheets(Worksheets.count)).Name = xName & ""
    Sheets(xName & "").Move after:=Worksheets(Worksheets.count)
    Sheets(xName & "").Visible = False
    Exit Sub
End If
    Cancel = True
End Sub

5. Kliknite Shrani , da shranite kodo in nato zaprite delovni zvezek.

Delovni zvezek je bil shranjen kot Excelov makro omogočen delovni zvezek z Shrani in Shrani kot funkcije onemogočene.

Opombe: Zdi se, da se spremembe shranijo v trenutni delovni list vsakič, ko spremenite in shranite delovni zvezek. Toda po zaprtju in ponovnem odpiranju delovnega zvezka boste ugotovili, da sprememb ni bilo mogoče shraniti.


Najboljša orodja za pisarniško produktivnost

Kutools za Excel rešuje večino vaših težav in poveča produktivnost za 80%

  • Ponovna uporaba: Hitro vstavite zapletene formule, grafikoni in vse, kar ste že uporabljali; Šifriraj celice z geslom; Ustvari poštni seznam in pošiljanje e-pošte ...
  • Vrstica Super Formula (enostavno urejanje več vrstic besedila in formule); Bralna postavitev (enostavno branje in urejanje velikega števila celic); Prilepite v filtrirani obseg...
  • Združi celice / vrstice / stolpce brez izgube podatkov; Vsebina razdeljenih celic; Združi podvojene vrstice / stolpce... prepreči podvojene celice; Primerjaj obsege...
  • Izberite Duplicate ali Unique Vrstice; Izberite prazne vrstice (vse celice so prazne); Super Find in Fuzzy Find v mnogih delovnih zvezkih; Naključna izbira ...
  • Natančna kopija Več celic brez spreminjanja sklica formule; Samodejno ustvarjanje referenc na več listov; Vstavi oznake, Potrditvena polja in še več ...
  • Izvleček besedila, Dodaj besedilo, Odstrani po položaju, Odstrani presledek; Ustvari in natisni vmesne seštevke strani Pretvarjanje med vsebino celic in komentarji...
  • Super filter (shranite in uporabite sheme filtrov za druge liste); Napredno razvrščanje glede na mesec / teden / dan, pogostost in drugo; Poseben filter s krepko, ležeče ...
  • Združite delovne zvezke in delovne liste; Spoji tabele na podlagi ključnih stolpcev; Razdelite podatke na več listov; Paketna pretvorba xls, xlsx in PDF...
  • Več kot 300 zmogljivih funkcij. Podpira Office / Excel 2007-2019 in 365. Podpira vse jezike. Preprosta namestitev v vašem podjetju ali organizaciji. Vse funkcije 30-dnevnega brezplačnega preskusa. 60-dnevno jamstvo za vračilo denarja.
zavihek kte 201905

Kartica Office prinaša vmesnik z zavihki v Office in poenostavi vaše delo

  • Omogočite urejanje in branje z zavihki v Wordu, Excelu, PowerPointu, Publisher, Access, Visio in Project.
  • Odprite in ustvarite več dokumentov v novih zavihkih istega okna in ne v novih oknih.
  • Poveča vašo produktivnost za 50% in vsak dan zmanjša na stotine klikov z miško!
dno pisarniške mize
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Joe · 10 months ago
    Please, I do not want someone to copy or save my excel file, how can I remove save or save as?

  • To post as a guest, your comment is unpublished.
    Madhusudhan · 1 years ago
    Hello I am a fan of this website...I used to try the code. It works flawlessly. But it disables "Save option" too. I am not able to save the Excel sheet. What I need is to disable only the feature "Save As" I read the other user's comments too. ThisWorkbookSaved = True is not working for me as well. Could you please help? Thanks a lot for all your contributions.
  • To post as a guest, your comment is unpublished.
    Naomi · 2 years ago
    I keep getting debug error
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Good day,
      Which Excel version do you use?
  • To post as a guest, your comment is unpublished.
    Rogue · 3 years ago
    Just to help whoever else reads this article looking for help with suppressing the save button I thought I'd place the answer down here as "Crystal" doesn't seem to be answering the question....


    If you place the workbook in "Design Mode" and then hit SAVE it should work.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Rogue,
      I miss the point of the problem. Thank you so much for your help and sharing.

      Best Regards
  • To post as a guest, your comment is unpublished.
    What they said · 4 years ago
    As TEE and LES posted, how do we save the file with the macro in?
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Hi,
      Thank you for your question. The article is updated to support saving the code into workbook now.
  • To post as a guest, your comment is unpublished.
    Les Battersthee · 4 years ago
    As TEE posted, how do we save the file with the macro in? It is not there when I reopen. I am also now getting a bug on the ThisWorkbookSaved = True bit.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Les,
      Thank you for your question. The article is updated to support saving the code into workbook now.
  • To post as a guest, your comment is unpublished.
    tee · 4 years ago
    this doesn't work. I can't save the code it's gone once I reopen the file. How do I save the code?
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear tee,
      Thank you for your question. The article is updated to support saving the code into workbook now.
      • To post as a guest, your comment is unpublished.
        jen · 2 years ago
        dear
        the article is not updated. it doesnt work
        • To post as a guest, your comment is unpublished.
          crystal · 2 years ago
          Hi jen,
          The article has been updated again with the problem solving. Please have a try. Thank you for your comment.
          • To post as a guest, your comment is unpublished.
            I.C. Problems · 2 years ago
            The update to the code adds a sheet, but never actually checks whether there is a TRUE/FALSE value in that sheet. The update fixes nothing, it just creates a useless sheet within the workbook.

            I think you forgot to do a check whether there is a TRUE/FALSE value on that sheet.