Tonight I want to automatically protect and unprotect all Microsoft Excel Worksheets in my Workbook with password, instead of doing it manually, I put these following Excel VBA macro code in my Workbook.
Public Sub ProtectAllSheets()
Dim objSheet As Worksheet
'Protecting all worksheets with password
For Each objSheet In Worksheets
If objSheet.ProtectContents = False Then objSheet.Protect "a@#&ladfl&^"
Next objSheet
End Sub
Public Sub UnProtectAllSheets()
Dim objSheet As Worksheet
'UnProtecting all worksheets with password
For Each objSheet In Worksheets
If objSheet.ProtectContents = True Then objSheet.Unprotect "a@#&ladfl&^"
Next objSheet
End Sub
We only need to call the procedure ProtectAllSheets to protect with password all Excel Worksheets in our Workbook, and calling UnProtectAllSheets will reversed the effect.
Hi,
Wouldn’t the password be plainly visible to anyone looking at the VB code? Doesn’t it defeat the purpose of having a password?
I am trying to achieve something similar and came across your post in a search.
Do you know whether it is possible to have the code pop-up a password box such that you will have to put in your password in order to un/protect the worksheets in a way that you will not have to write your password into the script?
Cheers,
Yoav
Pingback: reverse mortgage pros and cons
Pingback: reverse mortgage lender
Pingback: deutsch connectors
Pingback: debt collection agency
Pingback: dating factory bonus
Pingback: collection agency rates
Pingback: Alternative Energy Projects
Pingback: Domitila Escarcega
Pingback: collection agency
Pingback: Bollywood Bhangra
Pingback: hair salon st catharines
Pingback: easy crm
Pingback: collection agency newsletter
Pingback: buy backlinks
Pingback: wedding photographer calgary
Pingback: Wedding Photography
Pingback: ??????????? 2012
Pingback: Saints Comforter Set Sales
Pingback: buy facebook fans
Pingback: Erotiek Groothandel
Pingback: Dofollow
Pingback: Landscape Gardeners North London
Pingback: footlocker coupon codes
Pingback: Justin Bieber
Pingback: juegos de niƱas
Pingback: hsbc credit card payment
Pingback: continue to the website
Pingback: credit auto
Pingback: assurance auto pas cher
Pingback: prets personnels
Pingback: tatuaggi maori
Pingback: transunion
Pingback: pedicure
Pingback: learn internet marketing
Pingback: refrigerator reviews
Pingback: click here
Pingback: pay per click
Pingback: SEO Services
Pingback: ??? ???
Pingback: right here
Pingback: europeana portal
Pingback: Best Little Black Cocktail Dress
Pingback: ????? ??????
Pingback: promo code for amazon
Pingback: fishing tackle
Pingback: more info
Pingback: ford new car warranty 2008
Pingback: Document Solutions
Pingback: Otis