Mahesh has a number of Excel workbooks, all stored in the same folder. He wonders if it is possible to assign a password to the entire folder so that all the workbooks are protected.
The short answer is no, you can't do that in Excel. There are a number of different techniques you can apply that will provide the desired result, however. The first method is to use a program such as WinZip to combine all the workbooks into a single zip file. This file can be password protected (in WinZip) so that not everyone can open it. You could then open the zip file (using your password) and double-click on any workbook in it in order to modify it with Excel. The result, for all intents and purposes, is that you have a "folder" (the zip file) that is protected, while the individual files it contains are not.
Another approach is to place the workbook folder on a network drive and then have the network admin protect the folder. Most network operating systems allow administrators to control who can have access to specific folders and their contents.
A third approach is to use a third-party program to protect the folder. A quick search of the Web will no doubt turn up several candidates, such as the following:
http://www.folder-password-expert.com
You can also use an Excel macro to protect the workbooks. While it does not offer true folder-level protection, it does allow you to protect all the workbooks in the folder in as easy a manner as possible.
Sub ProtectAll() Dim wBk As Workbook Dim sFileSpec As String Dim sPathSpec As String Dim sFoundFile As String sPathSpec = "C:\MyPath\" sFileSpec = "*.xls" sFoundFile = Dir(sPathSpec & sFileSpec) Do While sFoundFile <> "" Set wBk = Workbooks.Open(sPathSpec & sFoundFile) With wBk Application.DisplayAlerts = False wBk.SaveAs FileName:=.FullName, _ Password:="swordfish" Application.DisplayAlerts = True End With Set wBk = Nothing Workbooks(sFoundFile).Close False sFoundFile = Dir Loop End Sub
Make sure you change the sPathSpec and sFileSpec variables, near the beginning of the code, to reflect the folder containing the workbooks and the pattern for the names of the workbooks you want protected. The macro assumes that all the workbooks are unprotected; if any are not, the macro will prompt for the workbook's password.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2878) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Protecting an Entire Folder of Workbooks.
Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!
Having problems with using macros in a protected workbook? There could be any number of causes (and solutions) as ...
Discover MoreDo you want user-entered data to be immediately protected so that it cannot be changed? This can be done relatively ...
Discover MoreOne of the security features built-in to Excel is the ability to save a workbook using a password that limits access to ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2018-01-17 06:06:33
Ola Gunaerson
Good day Sir, thank you for sharing your code.
I have a similar problem, monthly I generate reports and I have to protect each workbook before sending the report.
Usually, it takes three times the effort put in to protect.
There are 40 worksheets in an Excel workbook, I need a code that allows me to protect these workbooks using 40 different preset passwords.
Another scenario similar to that stated above is having 40 files in a folder and running a script that assigns the 40 different passwords to them.
Please note that my VBA skills are not the best and I would need assistance in interpreting the codes down to granular level.
2016-12-30 15:59:44
Elbio
how can we adjust this to comb through any child folders and protect workbooks in those? I now have 5 parent folders with a few hundred child folders that I need to protect.
2016-07-20 16:41:00
Matt Ga Mark
It really works. Thank you so much.
2016-07-14 12:47:15
Scot
Works GREAT!
I have code that splits my worksheet into separate workbooks, which works well. However, I need to password protect these workbooks with a different password based on the name of the workbook .... any suggestions?
2016-04-28 10:25:15
Elbio
Worked beautifully, thank you!!!
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2021 Sharon Parq Associates, Inc.
Comments