Hi jer,
jer wrote:
I have searched help in excel and have not seen references to this.
Is it possible to set a password for a folder and not the individuals
workbooks in that folder in excel. Failing that, would it be
possible to assign a password via code to multiple workbooks in a
folder
The best way to do this, assuming you're in a networked environment, is to
use Windows-based security on the folder. That will protect the workbooks
better than any form of Excel protection. If you're not sure how to do that
(or don't have the necessary rights), check with your sys admin.
Here's an example that will protect all workbooks within the folder C:\test
with the password "test":
Private Const msFOLDER_PATH As String = "C:\test"
Sub demo()
Dim fso As Object
Dim fil As Object
Set fso = CreateObject("Scripting.FileSystemObject")
For Each fil In fso.GetFolder(msFOLDER_PATH).Files
If fil.Type = "Microsoft Excel Worksheet" Then
With Workbooks.Open(fil.Path, False)
Application.DisplayAlerts = False
.SaveAs Filename:=.FullName, Password:="test"
Application.DisplayAlerts = True
.Close False
End With
End If
Next fil
Set fso = Nothing
End Sub
--
Regards,
Jake Marx
www.longhead.com
[please keep replies in the newsgroup - email address unmonitored]