macro to password protect exel file
Hi,
I need to password protect hundreds of exel files with the same password, but my boss wants them done one by one (as opposed to a zip file). The files are in different directories and have different names. Can I create a macro that will do the following once I have the file open? Go to Save As Go to Tools Select General Options Enter password to protect (i.e. 1234) click OK Retype password Click OK Save I have been doing this for the past hour one file at a time and my fingers are really tired now. Any help is GREATLY appreciated. |
macro to password protect exel file
Look at help on the Workbook.SaveAs command. Password is one of the
arguments. Sub PasswordFiles() Dim sFname as String, sPath as String sPath = "C:\My Folder\" sFname = Dir(sPath & "*.xls") do While sFname < "" Workbooks.Open sPath & sFname Application.DisplayAlerts = False ActiveWorkbook.Saves FileName:=ActiveWorkbook.fullname, _ FileFormat:=xlWorkbookNormal, Password:="1234" Application.DisplayAlerts = True ActiveWorkbook.Close SaveChanges:=False sFname = Dir() Loop End Sub -- Regards, Tom Ogilvy "anelh6" wrote in message ... Hi, I need to password protect hundreds of exel files with the same password, but my boss wants them done one by one (as opposed to a zip file). The files are in different directories and have different names. Can I create a macro that will do the following once I have the file open? Go to Save As Go to Tools Select General Options Enter password to protect (i.e. 1234) click OK Retype password Click OK Save I have been doing this for the past hour one file at a time and my fingers are really tired now. Any help is GREATLY appreciated. |
All times are GMT +1. The time now is 12:45 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com