Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can a Macro on exel be set with a password? Dave Excel Worksheet Functions 2 October 1st 07 09:11 PM
Password Protect CSV File Jasmine Excel Discussion (Misc queries) 3 September 21st 05 04:34 PM
how do i password protect an .xls file? how do i unlock it for automation. e.g. want to unlock and access a .xls from another .xls macro. Daniel Excel Worksheet Functions 1 June 24th 05 02:59 PM
password protect .csv file Jennifer Boe Excel Discussion (Misc queries) 1 June 1st 05 05:16 PM
Password protect folders in Exel Nick dalton Excel Discussion (Misc queries) 0 April 29th 05 01:30 PM


All times are GMT +1. The time now is 11:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"