Direkt zum Inhalt

Wie kann ich die Optionen Speichern und Speichern unter in Excel deaktivieren oder nicht zulassen?

Wenn wir auf Speichern oder Speichern unter klicken, werden unsere geänderten Daten in der Arbeitsmappe normalerweise sofort gespeichert. Manchmal darf Ihre Excel-Datei jedoch nicht von anderen Benutzern geändert und gespeichert werden, wenn diese die Datei lesen. Dieser Artikel enthält eine VBA-Methode zum Deaktivieren der Optionen Speichern und Speichern unter in Excel.

Deaktivieren Sie die Optionen Speichern und Speichern unter mit VBA-Code


Deaktivieren Sie die Optionen Speichern und Speichern unter mit VBA-Code

Sie können den folgenden VBA-Code ausführen, um die Optionen Speichern und Speichern unter in Excel zu deaktivieren.

1. In der Arbeitsmappe müssen Sie die Funktionen Speichern & Speichern unter deaktivieren. Drücken Sie bitte Andere + F11 Tasten gleichzeitig zum Öffnen der Microsoft Visual Basic für Applikationen Fenster.

2. In dem Microsoft Visual Basic für Applikationen Fenster, Doppelklick DiesesWorkbook Kopieren Sie in der linken Leiste den folgenden VBA 1, fügen Sie ihn in das Codefenster ein und klicken Sie dann auf Speichern Taste. Siehe Screenshot:

VBA 1: Deaktivieren Sie die Optionen Speichern und Speichern unter in Excel

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

3. In der Öffnung Speichern unter Wählen Sie im Fenster einen Ordner zum Speichern der Arbeitsmappe aus, benennen Sie die Arbeitsmappe nach Bedarf und wählen Sie Excel Makroaktivierte Arbeitsmappe von dem Speichern als Typ Dropdown-Liste, und klicken Sie schließlich auf die Speichern .

4. Kopieren Sie nun den folgenden VBA 2 und fügen Sie ihn in den ein DiesesWorkbook Codefenster. Siehe Screenshot.

VBA 2: Deaktivieren Sie die Optionen Speichern und Speichern unter in Excel

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. Klicken Sie auf die Speichern Klicken Sie auf die Schaltfläche, um den Code zu speichern, und schließen Sie dann die Arbeitsmappe.

Die Arbeitsmappe wurde als Excel Macro-Enabled Workbook mit dem gespeichert Speichern und Speichern unter Funktionen deaktiviert.

Note: Es scheint, dass Änderungen jedes Mal, wenn Sie die Arbeitsmappe ändern und speichern, im aktuellen Arbeitsblatt gespeichert werden. Nach dem Schließen und erneuten Öffnen der Arbeitsmappe werden Sie jedoch feststellen, dass die Änderungen nicht gespeichert werden konnten.

Beste Office-Produktivitätstools

🤖 Kutools KI-Assistent: Revolutionieren Sie die Datenanalyse basierend auf: Intelligente Ausführung   |  Code generieren  |  Erstellen Sie benutzerdefinierte Formeln  |  Analysieren Sie Daten und erstellen Sie Diagramme  |  Rufen Sie Kutools-Funktionen auf...
Beliebte Funktionen: Suchen, markieren oder identifizieren Sie Duplikate   |  Leere Zeilen löschen   |  Kombinieren Sie Spalten oder Zellen, ohne Daten zu verlieren   |   Runde ohne Formel ...
Super-Lookup: VLookup mit mehreren Kriterien    VLookup mit mehreren Werten  |   VLookup über mehrere Blätter hinweg   |   Unscharfe Suche ....
Erweiterte Dropdown-Liste: Erstellen Sie schnell eine Dropdown-Liste   |  Abhängige Dropdown-Liste   |  Mehrfachauswahl Dropdown-Liste ....
Spaltenmanager: Fügen Sie eine bestimmte Anzahl von Spalten hinzu  |  Spalten verschieben  |  Schalten Sie den Sichtbarkeitsstatus ausgeblendeter Spalten um  |  Vergleichen Sie Bereiche und Spalten ...
Ausgewählte Funktionen: Rasterfokus   |  Designansicht   |   Große Formelleiste    Arbeitsmappen- und Blattmanager   |  Ressourcen (Autotext)   |  Datumsauswahl   |  Arbeitsblätter kombinieren   |  Zellen verschlüsseln/entschlüsseln    Senden Sie E-Mails nach Liste   |  Superfilter   |   Spezialfilter (Filter fett/kursiv/durchgestrichen...) ...
Top 15 Toolsets12 Text Tools (Text hinzufügen, Zeichen entfernen, ...)   |   50+ Chart Typen (Gantt-Diagramm, ...)   |   40+ Praktisch Formeln (Berechnen Sie das Alter basierend auf dem Geburtstag, ...)   |   19 Einfügen Tools (QR-Code einfügen, Bild aus Pfad einfügen, ...)   |   12 Umwandlung (Conversion) Tools (Zahlen zu Wörtern, Currency Conversion, ...)   |   7 Zusammenführen & Teilen Tools (Erweiterte Zeilen kombinieren, Zellen teilen, ...)   |   ... und mehr

Verbessern Sie Ihre Excel-Kenntnisse mit Kutools für Excel und erleben Sie Effizienz wie nie zuvor. Kutools für Excel bietet über 300 erweiterte Funktionen, um die Produktivität zu steigern und Zeit zu sparen.  Klicken Sie hier, um die Funktion zu erhalten, die Sie am meisten benötigen ...

Beschreibung


Office Tab Bringt die Oberfläche mit Registerkarten in Office und erleichtert Ihnen die Arbeit erheblich

  • Aktivieren Sie das Bearbeiten und Lesen von Registerkarten in Word, Excel und PowerPoint, Publisher, Access, Visio und Project.
  • Öffnen und erstellen Sie mehrere Dokumente in neuen Registerkarten desselben Fensters und nicht in neuen Fenstern.
  • Steigert Ihre Produktivität um 50 % und reduziert jeden Tag Hunderte von Mausklicks für Sie!
Comments (28)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
When I try to save this in the code window, it shows an error message about Add, in the line:
Sheets.Add(after:=Worksheets(Worksheets.Count)).Name = xName & ""

how do I fix?
This comment was minimized by the moderator on the site
It is possible that user receiving the file will disable the macros and controlwill not work. Please help understand.
This comment was minimized by the moderator on the site
Hi Deepak Kachare,
If you don't want others users disable the macros after they receiving the file, you can hide the macro code that no one can open and see it.
See if the method in the following article can help you.
How to Protect and Hide Excel Macros
This comment was minimized by the moderator on the site
Thanks for your response. I think the link is an erroneous one. Could you please help with the link.
This comment was minimized by the moderator on the site
Hi DEEPAK KACHARE,
Sorry for the mistake. To protect and hide Excel macros, you need to configure as follows.
1. Click the Alt + F11 keys to open the VBA editor.
2. In the editor, click Tools > VBAProject Properties.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/vba3.png
3. In the VBAProject Properties dialog box, go to the Protection tab, check the Lock project for viewing box, enter password and finally click OK.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/vba4.png
From now on, anyone (including yourself) who wants to open the VBA editor of this workbook, a password is required.
This comment was minimized by the moderator on the site
I've just discovered that as soon as I place a shortcut to this file in another location (where the others are going to access it) all my protections no longer work. The sheet is not protected (which I have previously set), the workbook is not protected (which I have also previously set) and the Save-Save As ability is now there, as if the VBA code were not there at all. If I go to the original file, it all still works.

What is it about the shortcut that is stripping all the protections away?
This comment was minimized by the moderator on the site
Hi Rochelley,
The VBA code cannot figure out which way the workbook is opened. So it can't stop others from changing the file by opening it through a shortcut.
Sorry I can't help to with this problem.
For the first issue you mentioned above, I need time to see if I can handle it.
This comment was minimized by the moderator on the site
Hi, Thanks very much, this is exactly what I need, to prevent others from saving or saving as a file in any location, and it is working for me, thanks to the comment about "Design Mode".

However, I still need to be able to make edits to the file periodically and save the changes. Must I delete the VBA code first, make the changes, Save, and then add the VBA code back in again to prevent others from saving? Or is there a simpler way to make edits and save while leaving the VBA code intact?
This comment was minimized by the moderator on the site
Hi Rochelley,
Thank you for your feedback. The VBA code has been updated as follow. You need to:
1. Press the Alt + F11 keys to open the Visual Basic editor.
2. In the Visual Basic editor, double click ThisWorkbook in the left Project pane, and then copy the following VBA code into ThisWorkbook (Code) window.
3. Save the code and save the workbook as an Excel Macro-Enabled Workbook.
Notes:
1) In the code, "Win10x64Test" stands for the username in your operating system. Please change it to your own username.
2) After adding the code, you can edit the workbook and save it as usual. But if someone else gets this workbook, the Save and Save as options will not be avaliable.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Updated by Extendoffice 20220930
    ThisWorkbook.Saved = True
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim xName As String
xName = "Win10x64Test" 'The username in your operating system

If xName <> Environ("username") Then
Cancel = True
End If
End Sub
This comment was minimized by the moderator on the site
For all of those who encountered the error where after already doing this once, when they try do it again the code won't save:

Go to the bottom of the excel file where it shows the sheets
Right-click the sheets
Press Unhide
Delete the sheet called CancelBeforeSave
This comment was minimized by the moderator on the site
Brilliant !   
This comment was minimized by the moderator on the site
Thanks for your reply. Highly appreciated. I want you to guide me how to send a saved file to a friend who can open my file but only read or edit it, but can not not save the file in any folder.
1. For instance I have a saved file, which I want to send to "A" He opens the saved file but after opening he reads or makes any changes in my file, he can not save it at his end in any folder.
2. I have got code form internet which disallows to save. But in this case when I copy and paste the code, the file does not save. So I can not send the file to him
3. How can I send the file to Party "A" with a saved code in the hope he can not save the file.
This comment was minimized by the moderator on the site
I tried to use the code for NOT SAVING the file. But it did not work. It saves the file.
This comment was minimized by the moderator on the site
Please, I do not want someone to copy or save my excel file, how can I remove save or save as?
This comment was minimized by the moderator on the site
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.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations