Ana içeriğe atla

Excel'de Kaydet ve Farklı Kaydet seçeneklerini nasıl devre dışı bırakabilirim veya izin vermeyebilirim?

Normalde, Kaydet veya Farklı Kaydet işlevini tıkladığımızda, çalışma kitabındaki değiştirilmiş verilerimiz bir kerede kaydedilecektir. Ancak bazen, Excel dosyanızın diğer kullanıcılar dosyayı okurken değiştirmesine ve kaydetmesine izin verilmez. Bu makale, Excel'deki Kaydet ve Farklı Kaydet seçeneklerini devre dışı bırakmak için VBA yöntemi sağlar.

VBA kodu ile Kaydet ve Farklı Kaydet seçeneklerini devre dışı bırakın


VBA kodu ile Kaydet ve Farklı Kaydet seçeneklerini devre dışı bırakın

Excel'de Kaydet ve Farklı Kaydet seçeneklerini devre dışı bırakmak için aşağıdaki VBA kodunu çalıştırabilirsiniz.

1. Çalışma kitabında Kaydet ve Farklı Kaydet işlevlerini devre dışı bırakmanız gerekir, lütfen Ara Toplam + F11 anahtarları aynı anda açmak için Uygulamalar için Microsoft Visual Basic pencere.

2. içinde Uygulamalar için Microsoft Visual Basic pencere, çift tıklama Bu Çalışma Kitabı sol çubukta, aşağıdaki VBA 1'i kopyalayıp Kod penceresine yapıştırın ve ardından İndirim buton. Ekran görüntüsüne bakın:

VBA 1: Excel'de Kaydet ve Farklı Kaydet seçeneklerini devre dışı bırakın

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

3. Açılışta Farklı Kaydet penceresinde, çalışma kitabını kaydetmek için bir klasör seçin, çalışma kitabını ihtiyacınız olduğu gibi adlandırın ve Excel Makro Etkin Çalışma Kitabı itibaren Kayıt türü açılır listeyi ve son olarak İndirim düğmesine basın.

4. Şimdi aşağıdaki VBA 2'yi kopyalayıp Bu Çalışma Kitabı kod penceresi. Ekran görüntüsüne bakın.

VBA 2: Excel'de Kaydet ve Farklı Kaydet seçeneklerini devre dışı bırakın

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. Tıklayın İndirim düğmesine basarak kodu kaydedin ve ardından çalışma kitabını kapatın.

Çalışma kitabı, Excel Makro Etkin Çalışma Kitabı olarak kaydedildi. İndirim ve Farklı Kaydet işlevler devre dışı bırakıldı.

not: Çalışma kitabını her değiştirdiğinizde ve kaydettiğinizde, değişiklikler geçerli çalışma sayfasına kaydediliyor gibi görünüyor. Ancak çalışma kitabını kapatıp yeniden açtıktan sonra, değişikliklerin kaydedilemediğini göreceksiniz.

En İyi Ofis Üretkenlik Araçları

🤖 Kutools AI Yardımcısı: Aşağıdakilere dayalı olarak veri analizinde devrim yaratın: Akıllı Yürütme   |  Kodunu oluşturun  |  Özel Formüller Oluşturun  |  Verileri Analiz Edin ve Grafikler Oluşturun  |  Kutools İşlevlerini Çağır...
Popüler Özellikler: Yinelenenleri Bul, Vurgula veya Tanımla   |  Boş Satırları Sil   |  Veri Kaybı Olmadan Sütunları veya Hücreleri Birleştirin   |   Formülsüz Tur ...
Süper Arama: Çoklu Ölçütlü VLookup    Çoklu Değer VLookup  |   Birden Çok Sayfada VLookup   |   Bulanık Arama ....
Gelişmiş Açılır Liste: Hızla Açılır Liste Oluşturun   |  Bağımlı Açılır Liste   |  Çoklu Seçim Açılır Liste ....
Sütun Yöneticisi: Belirli Sayıda Sütun Ekleme  |  Sütunları Taşı  |  Gizli Sütunların Görünürlük Durumunu Değiştir  |  Aralıkları ve Sütunları Karşılaştırın ...
Öne Çıkan Özellikler: Izgara Odağı   |  Tasarım görünümü   |   Büyük Formül Çubuğu    Çalışma Kitabı ve Sayfa Yöneticisi   |  Kaynak Kütüphanesi (Otomatik metin)   |  Tarih Seçici   |  Çalışma Sayfalarını Birleştirin   |  Hücreleri Şifrele/Şifresini Çöz    E-postaları Listeye Göre Gönder   |  Süper Filtre   |   Özel Filtre (kalın/italik/üstü çizili filtre...) ...
En İyi 15 Araç Seti12 Metin Tools (Metin ekle, Karakterleri Kaldır, ...)   |   50+ Grafik Türleri (Gantt şeması, ...)   |   40+ Pratik Formüller (Yaşı doğum gününe göre hesapla, ...)   |   19 sokma Tools (QR Kodunu Girin, Yoldan Resim Ekle, ...)   |   12 Dönüştürme Tools (Sayılardan Kelimelere, Para Birimi Dönüştürme, ...)   |   7 Birleştir ve Böl Tools (Gelişmiş Kombine Satırları, Bölünmüş hücreler, ...)   |   ... ve dahası

Kutools for Excel ile Excel Becerilerinizi Güçlendirin ve Daha Önce Hiç Olmadığı Gibi Verimliliği Deneyimleyin. Kutools for Excel, Üretkenliği Artırmak ve Zamandan Tasarruf Etmek için 300'den Fazla Gelişmiş Özellik Sunar.  En Çok İhtiyacınız Olan Özelliği Almak İçin Buraya Tıklayın...

Açıklama


Office Tab, Office'e Sekmeli Arayüz Getirir ve İşinizi Çok Daha Kolay Hale Getirir

  • Word, Excel, PowerPoint'te sekmeli düzenlemeyi ve okumayı etkinleştirin, Publisher, Access, Visio ve Project.
  • Yeni pencereler yerine aynı pencerenin yeni sekmelerinde birden çok belge açın ve oluşturun.
  • Üretkenliğinizi% 50 artırır ve her gün sizin için yüzlerce fare tıklamasını azaltır!
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