Open Workbooks and Password Protect all Worksheets

  • Thread starter Thread starter K
  • Start date Start date
K

K

Hi all, I need macro which should open all excel workbooks one by one
in folder "C:\Document\Record\" and protect all worksheets in each
workbook with password "REC". I tried few my own experiments but I am
not getting any success. Please can any friend can help.
 
Hi K

Here is a basic macro
http://www.rondebruin.nl/copy4.htm

Replace the red code block with something like this

On Error Resume Next
For Each sh In mybook.Worksheets
If sh.ProtectContents = False Then
With sh
.Protect = "REC"
End With
Else
ErrorYes = True
End If
Next sh
 
Back
Top