Macro for protecting all the worksheets with password

DLimKTS

New Member
Joined
Nov 19, 2014
Messages
11
Hello,

I have about over 200 xls files and was asked to protect all the worksheets with password from being able to edit and print. Is there a macro available to protect them by batch? In need of help. Thank You.
 
Weird, still does not work. Does it matter it the worksheet contains images? Also, what if the worksheets are named unique instead of Sheet1, Sheet2....
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Perhaps you could upload copies of 3 or 4 of your files to a free site such as www.box.com. Once you do that, mark each file for 'Sharing' and you will be given a link for each file that you can post here. I could then use those files and do a test run on my computer and let you know what happens.
 
Upvote 0
To avoid Printing you will also need to add something like this in the ThisWorkbook module of all files:
Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)

    Cancel = True

End Sub
 
Upvote 0
Thanks mumps!! That worked. I just have to do a through QC since the workbook itself are showing some discrepancy. But your macro works perfect. Thank you so much.
 
Upvote 0
mumps, I did the test and everything works great. I found that some of the worksheet has a design chart and that's when the script will stop working.
 
Upvote 0
No, that code can be inserted while using mumps code but needs other coding to add a macro to the file you are opening with mumps code to apply a password.
 
Last edited:
Upvote 0
Have a look here: Programming In The VBA Editor
You are supposed to do a "Copy A Module From One Project To Another" or something like that. Sorry can't be of other help, goes beyond my knowledge.
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top