Open Workbooks and Password Protect all Worksheets

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.
 
R

Ron de Bruin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top