ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Password protecting multiple spreadsheets at once (https://www.excelbanter.com/excel-discussion-misc-queries/200142-password-protecting-multiple-spreadsheets-once.html)

Ron

Password protecting multiple spreadsheets at once
 
I have a folder with 8000 spreadsheets, is there a way to PW protect all of
them at once, or will they need to be done manually?
--
Ron

Sheeloo

Password protecting multiple spreadsheets at once
 
You need to write a Macro which will loop through all the files in the
specified folder and password protect all files.

Let me know if you want me to write that.

"Ron" wrote:

I have a folder with 8000 spreadsheets, is there a way to PW protect all of
them at once, or will they need to be done manually?
--
Ron


Ron

Password protecting multiple spreadsheets at once
 
Thanks, that would be great if you could write that for me....
--
Ron


"Sheeloo" wrote:

You need to write a Macro which will loop through all the files in the
specified folder and password protect all files.

Let me know if you want me to write that.

"Ron" wrote:

I have a folder with 8000 spreadsheets, is there a way to PW protect all of
them at once, or will they need to be done manually?
--
Ron


Sheeloo

Password protecting multiple spreadsheets at once
 
Ron,

Code (you can put this in a macro and run) with no error checking is given
below.
1. Replace "C:\" with the directory containing your files. Do not forget to
place '\' at the end of the path as I have done and enclose the path within
quotes.
2. It is assumed that all files in the directory are Excel files. This will
fail if this is not correct.
3. Also replace xyz123 with the password you want.

IMP: Do make a test folder, copy your files there and test this out...
before applying to your big folder. Even then do keep unprotected copies of
the fall till you are sure it works.

Sub SetPassword()
Dim fs, f, f1, fc, dirName, pw
dirName = "C:\"
pw = "xyz123"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(dirName)
Set fc = f.FileS
For Each f1 In fc
Workbooks.Open Filename:=dirName & f1.Name
Workbooks(Workbooks.Count).Activate
ActiveWorkbook.Password = pw
ActiveWorkbook.Close True
Next
MsgBox ("Password set on all files.")

End Sub

"Ron" wrote:

Thanks, that would be great if you could write that for me....
--
Ron


"Sheeloo" wrote:

You need to write a Macro which will loop through all the files in the
specified folder and password protect all files.

Let me know if you want me to write that.

"Ron" wrote:

I have a folder with 8000 spreadsheets, is there a way to PW protect all of
them at once, or will they need to be done manually?
--
Ron


Ron

Password protecting multiple spreadsheets at once
 
Thank you very much.....
--
Ron


"Sheeloo" wrote:

Ron,

Code (you can put this in a macro and run) with no error checking is given
below.
1. Replace "C:\" with the directory containing your files. Do not forget to
place '\' at the end of the path as I have done and enclose the path within
quotes.
2. It is assumed that all files in the directory are Excel files. This will
fail if this is not correct.
3. Also replace xyz123 with the password you want.

IMP: Do make a test folder, copy your files there and test this out...
before applying to your big folder. Even then do keep unprotected copies of
the fall till you are sure it works.

Sub SetPassword()
Dim fs, f, f1, fc, dirName, pw
dirName = "C:\"
pw = "xyz123"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(dirName)
Set fc = f.FileS
For Each f1 In fc
Workbooks.Open Filename:=dirName & f1.Name
Workbooks(Workbooks.Count).Activate
ActiveWorkbook.Password = pw
ActiveWorkbook.Close True
Next
MsgBox ("Password set on all files.")

End Sub

"Ron" wrote:

Thanks, that would be great if you could write that for me....
--
Ron


"Sheeloo" wrote:

You need to write a Macro which will loop through all the files in the
specified folder and password protect all files.

Let me know if you want me to write that.

"Ron" wrote:

I have a folder with 8000 spreadsheets, is there a way to PW protect all of
them at once, or will they need to be done manually?
--
Ron



All times are GMT +1. The time now is 09:22 AM.

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