Password Protect Worksheet: VBA Code to Protect Worksheet with Password on Close

رمز VBA لحماية ورقة العمل بكلمة مرور عند الإغلاق
جدول المحتويات

Password Protect Worksheet on Close with VBA (with Images)

ماذا فعلا:

When you want others to only view the workbook data and no editing should be permitted then you have to make sure you protect the workbook with password while closing it. So that even if someone tries to edit the data it will ask for the password unless they input the password data will not be editable.

The manual way of doing the same is

مراجعة - Protect Sheet and then يحفظ workbook.

Password Protect

لماذا فعلا:

If you make frequent updates in the workbook then Every time when you make changes in the workbook you have to make sure you protect it while closing. Some day if you forget to protect then the data will be editable by others.

The below VBA code will help you to protect the workbook automatically while closing the workbook. That means you don’t have to protect it manually everything when you make changes in the workbook.

كيف to password protect with VBA upon Close:

Step 1: Open the workbook that need to be protected and press Alt + F11




الخطوة 2: انسخ الكود التالي والصقه في نافذة محرر VBA واحفظ المصنف.

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Sheets(“Sheet1″).Protect Password:=”Your Password Here”   ‘Replace “Sheet1” with your sheet name and “Your Password Here” with the password of your choice.

ActiveWorkbook.Save

نهاية الفرعية

ملحوظة: Workbook should be saved in a macro enabled format (.xlm, .xlsm, .xlsb etc.) also make sure you protect the VBA code as well. 🙂

That’s It Now Onward your Data will be Safe Always!!

Picture of Anson Antony
أنسون أنتوني
أنسون هو مؤلف مساهم ومؤسس في www.askeygeek.com. لقد كان تعلم أي شيء جديد هو شغفه دائمًا، ASKEYGEEK.com هو نتيجة شغفه بالتكنولوجيا والأعمال. لقد حصل على عقد من الخبرة المتنوعة في الاستعانة بمصادر خارجية للعمليات التجارية، والمالية والمحاسبة، وتكنولوجيا المعلومات، والتميز التشغيلي وذكاء الأعمال. خلال فترة عمله، عمل في مؤسسات مثل Genpact وHewlett Packard وM*Modal وCapgemini في أدوار ومسؤوليات مختلفة. بعيدًا عن الأعمال والتكنولوجيا، فهو من عشاق الأفلام ويقضي ساعات معًا في مشاهدة وتعلم السينما وصانع أفلام أيضًا!

اترك تعليقاً

لن يتم نشر عنوان بريدك الإلكتروني. الحقول الإلزامية مشار إليها بـ *

تهانينا!
لقد فعلتها،
لا تغلق!

الحصول على ما يصل الى 60.000 أرصدة شخصيات UberTTS مجانًا!!!

هذه النافذة المنبثقة لن تظهر متروك لكم مرة أخرى!!!

أوبر تي تي إس
Share to...