ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open Workbooks and Password Protect all Worksheets (https://www.excelbanter.com/excel-programming/431735-open-workbooks-password-protect-all-worksheets.html)

K[_2_]

Open Workbooks and Password Protect all Worksheets
 
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.

Ron de Bruin

Open Workbooks and Password Protect all Worksheets
 
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



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"K" wrote in message ...
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.



All times are GMT +1. The time now is 02:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com